Class: Filterameter::Registries::FilterRegistry

Inherits:
SubRegistry
  • Object
show all
Defined in:
lib/filterameter/registries/filter_registry.rb

Overview

# Filter Registry

Class FilterRegistry is a collection of the filters. It captures the filter declarations when classes are loaded, then uses the injected FilterFactory to build the filters on demand as they are needed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SubRegistry

#add, #fetch, #parameter_names

Constructor Details

#initialize(factory) ⇒ FilterRegistry

Returns a new instance of FilterRegistry.



12
13
14
15
# File 'lib/filterameter/registries/filter_registry.rb', line 12

def initialize(factory)
  super
  @ranges = {}
end

Instance Attribute Details

#rangesObject (readonly)

Returns the value of attribute ranges.



10
11
12
# File 'lib/filterameter/registries/filter_registry.rb', line 10

def ranges
  @ranges
end

Instance Method Details

#build_declaration(name, options) ⇒ Object



17
18
19
20
21
# File 'lib/filterameter/registries/filter_registry.rb', line 17

def build_declaration(name, options)
  Filterameter::FilterDeclaration.new(name, options).tap do |fd|
    add_declarations_for_range(fd, options, name) if fd.range_enabled?
  end
end

#filter_declarationsObject



23
24
25
# File 'lib/filterameter/registries/filter_registry.rb', line 23

def filter_declarations
  @declarations.values
end