Module: SimpleSearchable::SearchableBy::FilterMethods

Defined in:
lib/simple_searchable.rb

Instance Method Summary collapse

Instance Method Details

#search_filter(name, arg) ⇒ Object



16
17
18
# File 'lib/simple_searchable.rb', line 16

def search_filter(name, arg)
  arg.present? ? send(name, arg) : all
end

#search_filter_all(names, opts) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/simple_searchable.rb', line 20

def search_filter_all(names, opts)
  result = self.all
  names.each do |n|
    unless opts[n].blank?
      opts[n].reject!(&:blank?) if opts[n].is_a?(Array)
      result = result.search_filter(n, opts[n])
    end
  end
  result
end