Class: RgGen::Core::Builder::LoaderRegistry
- Defined in:
- lib/rggen/core/builder/loader_registry.rb
Instance Method Summary collapse
- #create_loaders ⇒ Object
- #define_value_extractor(layers = nil, value, &body) ⇒ Object
- #ignore_value(layers = nil, value) ⇒ Object
- #ignore_values(layers = nil, values) ⇒ Object
-
#initialize ⇒ LoaderRegistry
constructor
A new instance of LoaderRegistry.
- #register_loader(loader) ⇒ Object
- #register_loaders(loaders) ⇒ Object
Constructor Details
#initialize ⇒ LoaderRegistry
Returns a new instance of LoaderRegistry.
7 8 9 10 11 |
# File 'lib/rggen/core/builder/loader_registry.rb', line 7 def initialize @loaders = [] @extractors = [] @ignore_values = {} end |
Instance Method Details
#create_loaders ⇒ Object
35 36 37 |
# File 'lib/rggen/core/builder/loader_registry.rb', line 35 def create_loaders @loaders.map { |loader| loader.new(@extractors, @ignore_values) } end |
#define_value_extractor(layers = nil, value, &body) ⇒ Object
21 22 23 |
# File 'lib/rggen/core/builder/loader_registry.rb', line 21 def define_value_extractor(layers = nil, value, &body) @extractors << create_extractor(layers, value, &body) end |
#ignore_value(layers = nil, value) ⇒ Object
25 26 27 |
# File 'lib/rggen/core/builder/loader_registry.rb', line 25 def ignore_value(layers = nil, value) ignore_values(layers, [value]) end |
#ignore_values(layers = nil, values) ⇒ Object
29 30 31 32 33 |
# File 'lib/rggen/core/builder/loader_registry.rb', line 29 def ignore_values(layers = nil, values) [layers].flatten.each do |layer| (@ignore_values[layer] ||= []).concat(Array(values)) end end |
#register_loader(loader) ⇒ Object
13 14 15 |
# File 'lib/rggen/core/builder/loader_registry.rb', line 13 def register_loader(loader) @loaders << loader end |
#register_loaders(loaders) ⇒ Object
17 18 19 |
# File 'lib/rggen/core/builder/loader_registry.rb', line 17 def register_loaders(loaders) @loaders.concat(Array(loaders)) end |