Module: Ronin::DB::Model::HasName::ClassMethods

Included in:
ASN
Defined in:
lib/ronin/db/model/has_name.rb

Overview

Class methods that are added when Ronin::DB::Model::HasName is included into a model.

Instance Method Summary collapse

Instance Method Details

#named(fragment) ⇒ Array<Model>

Finds models with names containing a given fragment of text.

Examples:

Exploit.named 'ProFTP'

Parameters:

  • fragment (String)

    The fragment of text to search for within the names of models.

Returns:

  • (Array<Model>)

    The found models.



75
76
77
78
79
# File 'lib/ronin/db/model/has_name.rb', line 75

def named(fragment)
  name_column = self.arel_table[:name]

  where(name_column.matches("%#{sanitize_sql_like(fragment)}%"))
end

#with_name(name) ⇒ Array<Model>

Finds all models with the matching name.

Parameters:

  • name (String)

    The name to search for.

Returns:

  • (Array<Model>)

    The found models.

Since:

  • 0.2.0



94
95
96
# File 'lib/ronin/db/model/has_name.rb', line 94

def with_name(name)
  where(name: name)
end