Module: Houston::Props::ClassMethods
- Defined in:
- app/concerns/houston/props.rb
Instance Method Summary collapse
Instance Method Details
#find_by_prop(prop_name, value) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/concerns/houston/props.rb', line 23 def find_by_prop(prop_name, value) result = with_prop(prop_name, value).limit(1).first if !result && block_given? result = yield value if result result.update_prop! prop_name, value else Rails.logger.info "\e[34mUnable to identify a #{name} where \e[1m#{prop_name}\e[0;34m=\e[1m#{value}\e[0m" end end result end |
#with_prop(prop_name, value) ⇒ Object
18 19 20 21 |
# File 'app/concerns/houston/props.rb', line 18 def with_prop(prop_name, value) Houston::Props.valid_prop_name!(prop_name) where(["props->>? = ?", prop_name, value.to_s]) end |