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
-
#named(fragment) ⇒ Array<Model>
Finds models with names containing a given fragment of text.
-
#with_name(name) ⇒ Array<Model>
Finds all models with the matching name.
Instance Method Details
#named(fragment) ⇒ Array<Model>
Finds models with names containing a given fragment of text.
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.
94 95 96 |
# File 'lib/ronin/db/model/has_name.rb', line 94 def with_name(name) where(name: name) end |