Module: Plok::Searchable::ClassMethods
- Defined in:
- app/models/concerns/plok/searchable.rb
Instance Method Summary collapse
- #plok_searchable(namespace: nil, fields: [], conditions: []) ⇒ Object
- #searchable_field(namespace, key, conditions) ⇒ Object
- #searchable_fields_list ⇒ Object
Instance Method Details
#plok_searchable(namespace: nil, fields: [], conditions: []) ⇒ Object
107 108 109 |
# File 'app/models/concerns/plok/searchable.rb', line 107 def plok_searchable(namespace: nil, fields: [], conditions: []) fields.each { |key| searchable_field(namespace, key, conditions) } end |
#searchable_field(namespace, key, conditions) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/models/concerns/plok/searchable.rb', line 92 def searchable_field(namespace, key, conditions) return if !!searchable_fields_list.dig(namespace.to_sym)&.detect do |field| field[:name] == key.to_sym end if searchable_fields_list[namespace.to_sym].blank? searchable_fields_list[namespace.to_sym] = [] end searchable_fields_list[namespace.to_sym] << { name: key.to_sym, conditions: conditions } end |
#searchable_fields_list ⇒ Object
111 112 113 |
# File 'app/models/concerns/plok/searchable.rb', line 111 def searchable_fields_list @searchable_fields_list ||= {} end |