Class: Administrate::Search

Inherits:
Object
  • Object
show all
Defined in:
lib/administrate/search.rb

Defined Under Namespace

Classes: Query

Instance Method Summary collapse

Constructor Details

#initialize(scoped_resource, dashboard, term) ⇒ Search

Returns a new instance of Search.



51
52
53
54
55
# File 'lib/administrate/search.rb', line 51

def initialize(scoped_resource, dashboard, term)
  @dashboard = dashboard
  @scoped_resource = scoped_resource
  @query = Query.new(term, valid_filters.keys)
end

Instance Method Details

#runObject



57
58
59
60
61
62
63
64
# File 'lib/administrate/search.rb', line 57

def run
  if query.blank?
    @scoped_resource.all
  else
    results = search_results(@scoped_resource)
    filter_results(results)
  end
end