Class: Filterameter::FilterFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/filterameter/filter_factory.rb

Overview

# Filter Factory

Class FilterFactory builds a filter from a FilterDeclaration.

Instance Method Summary collapse

Constructor Details

#initialize(model_class) ⇒ FilterFactory

Returns a new instance of FilterFactory.



8
9
10
# File 'lib/filterameter/filter_factory.rb', line 8

def initialize(model_class)
  @model_class = model_class
end

Instance Method Details

#build(declaration) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/filterameter/filter_factory.rb', line 12

def build(declaration)
  context = Helpers::DeclarationWithModel.new(@model_class, declaration)

  if declaration.nested?
    build_nested_filter(declaration, context)
  else
    build_filter(@model_class, declaration, context.scope?)
  end
end