Class: Kozeki::LoaderChain
- Inherits:
-
Object
- Object
- Kozeki::LoaderChain
- Defined in:
- lib/kozeki/loader_chain.rb
Instance Method Summary collapse
-
#initialize(loaders:, decorators:) ⇒ LoaderChain
constructor
A new instance of LoaderChain.
- #try_read ⇒ Object
Constructor Details
#initialize(loaders:, decorators:) ⇒ LoaderChain
Returns a new instance of LoaderChain.
3 4 5 6 |
# File 'lib/kozeki/loader_chain.rb', line 3 def initialize(loaders:, decorators:) @loaders = loaders @decorators = decorators end |
Instance Method Details
#try_read ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/kozeki/loader_chain.rb', line 8 def try_read(...) @loaders.each do |loader| source = loader.try_read(...) next unless source @decorators.each do |decorator| decorator.call(source., source) end return source end nil end |