Class: Dorsale::SmallData::FilterStrategyByKeyValue

Inherits:
FilterStrategy show all
Defined in:
app/filters/dorsale/small_data/filter_strategy_by_key_value.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key = nil) ⇒ FilterStrategyByKeyValue

Returns a new instance of FilterStrategyByKeyValue.



4
5
6
# File 'app/filters/dorsale/small_data/filter_strategy_by_key_value.rb', line 4

def initialize(key = nil)
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



2
3
4
# File 'app/filters/dorsale/small_data/filter_strategy_by_key_value.rb', line 2

def key
  @key
end

Instance Method Details

#apply(query, value) ⇒ Object



8
9
10
11
12
13
14
15
# File 'app/filters/dorsale/small_data/filter_strategy_by_key_value.rb', line 8

def apply(query, value)
  value = true  if value == "true"
  value = false if value == "false"
  value = nil   if value == "nil"
  value = nil   if value == "null"

  query.where("#{key} = ?", value)
end