Module: ErpTechSvcs::Extensions::ActiveRecord::IsJson::SingletonMethods
- Defined in:
- lib/erp_tech_svcs/extensions/active_record/is_json.rb
Instance Method Summary collapse
- #matches_is_json(attr_name, keyword, attr = nil) ⇒ Object
- #with_json_attribute(attr_name, attr, keyword) ⇒ Object
Instance Method Details
#matches_is_json(attr_name, keyword, attr = nil) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/erp_tech_svcs/extensions/active_record/is_json.rb', line 41 def matches_is_json(attr_name, keyword, attr=nil) if attr arel_table[attr_name.to_sym].matches("%\"#{attr}\":\"#{keyword}\"%"). or(arel_table[attr_name.to_sym].matches("%\"#{attr}\":#{keyword}%")) else arel_table[attr_name.to_sym].matches("%#{keyword}%") end end |
#with_json_attribute(attr_name, attr, keyword) ⇒ Object
50 51 52 |
# File 'lib/erp_tech_svcs/extensions/active_record/is_json.rb', line 50 def with_json_attribute(attr_name, attr, keyword) where(self.matches_is_json(attr_name, keyword, attr)) end |