Class: Quickfilter::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/quickfilter/filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table, field, operator, value, adapter) ⇒ Filter

Returns a new instance of Filter.



8
9
10
11
12
13
# File 'lib/quickfilter/filter.rb', line 8

def initialize(table, field, operator, value, adapter)
  self.field = "#{table}.#{field}"
  self.operator = operator
  self.value = value
  self.adapter = adapter
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



6
7
8
# File 'lib/quickfilter/filter.rb', line 6

def adapter
  @adapter
end

#fieldObject

Returns the value of attribute field.



6
7
8
# File 'lib/quickfilter/filter.rb', line 6

def field
  @field
end

#operatorObject

Returns the value of attribute operator.



6
7
8
# File 'lib/quickfilter/filter.rb', line 6

def operator
  @operator
end

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/quickfilter/filter.rb', line 6

def value
  @value
end

Instance Method Details

#buildObject



15
16
17
18
# File 'lib/quickfilter/filter.rb', line 15

def build
  return nil if self.value.blank?
  return Quickfilter::Handlers.get(self.operator, self.adapter).call(self.field, self.value)
end