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

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