Module: Shoppy::Concerns::Models::Optionable::ClassMethods
- Defined in:
- app/models/shoppy/concerns/models/optionable.rb
Overview
These are shared mothods, a.k.a class methods
Instance Method Summary collapse
-
#by_option_key(key) ⇒ Object
Query all model instances that have a given key, regardless of the valiue for that key.
-
#by_option_key_value(key, value) ⇒ Object
Query all model instance sthat have a given key/value pair.
Instance Method Details
#by_option_key(key) ⇒ Object
Query all model instances that have a given key, regardless of the valiue for that key.
49 50 51 |
# File 'app/models/shoppy/concerns/models/optionable.rb', line 49 def by_option_key(key) self.where("options ? :key", key: key) end |
#by_option_key_value(key, value) ⇒ Object
Query all model instance sthat have a given key/value pair.
55 56 57 58 |
# File 'app/models/shoppy/concerns/models/optionable.rb', line 55 def by_option_key_value(key, value) kv = key + "=>" + value self.where("options @> :kv", kv: kv) end |