Class: Madmin::Search

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scoped_resource, resource, term) ⇒ Search

Returns a new instance of Search.



7
8
9
10
11
# File 'lib/madmin/search.rb', line 7

def initialize(scoped_resource, resource, term)
  @resource = resource
  @scoped_resource = scoped_resource
  @query = term
end

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



5
6
7
# File 'lib/madmin/search.rb', line 5

def query
  @query
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
# File 'lib/madmin/search.rb', line 13

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