Class: MundaneSearch::Filters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mundane-search/filters/base.rb

Direct Known Subclasses

BlankParamsAreNil, Typical

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection, params = {}, options = {}) ⇒ Base

Returns a new instance of Base.



4
5
6
# File 'lib/mundane-search/filters/base.rb', line 4

def initialize(collection, params = {}, options= {})
  @collection, @params, @options = collection, params, options
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



3
4
5
# File 'lib/mundane-search/filters/base.rb', line 3

def collection
  @collection
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/mundane-search/filters/base.rb', line 3

def options
  @options
end

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/mundane-search/filters/base.rb', line 3

def params
  @params
end

Instance Method Details

#apply?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/mundane-search/filters/base.rb', line 8

def apply?
  true
end

#callObject



20
21
22
23
24
25
26
# File 'lib/mundane-search/filters/base.rb', line 20

def call
  if apply?
    [filtered_collection, filtered_params]
  else
    [collection, params]
  end
end

#filtered_collectionObject



12
13
14
# File 'lib/mundane-search/filters/base.rb', line 12

def filtered_collection
  collection
end

#filtered_paramsObject



16
17
18
# File 'lib/mundane-search/filters/base.rb', line 16

def filtered_params
  params
end