Class: Lore::Filters

Inherits:
Object show all
Defined in:
lib/lore/model/filters.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(accessor) ⇒ Filters

Returns a new instance of Filters.



8
9
10
11
12
# File 'lib/lore/model/filters.rb', line 8

def initialize(accessor)
  @accessor = accessor
  @input_filters  = {}
  @output_filters = {}
end

Instance Attribute Details

#input_filtersObject

Returns the value of attribute input_filters.



6
7
8
# File 'lib/lore/model/filters.rb', line 6

def input_filters
  @input_filters
end

#output_filtersObject

Returns the value of attribute output_filters.



6
7
8
# File 'lib/lore/model/filters.rb', line 6

def output_filters
  @output_filters
end

Instance Method Details

#add_input_filter(attr_name, &block) ⇒ Object



20
21
22
23
24
# File 'lib/lore/model/filters.rb', line 20

def add_input_filter(attr_name, &block)
  # Filters are mapped to attribute names disregarding their 
  # original table. 
  @input_filters[attr_name.to_sym] = block
end

#add_output_filter(attr_name, &block) ⇒ Object



26
27
28
29
30
# File 'lib/lore/model/filters.rb', line 26

def add_output_filter(attr_name, &block)
  # Filters are mapped to attribute names disregarding their 
  # original table. 
  @output_filters[attr_name.to_sym] = block
end

#inherit(base_model) ⇒ Object



14
15
16
17
18
# File 'lib/lore/model/filters.rb', line 14

def inherit(base_model)
  parent_filters = base_model.__filters__
  @input_filters.update(parent_filters.input_filters.dup)
  @output_filters.update(parent_filters.output_filters.dup)
end