Class: Payload::DecoratorChain Private
- Inherits:
-
Object
- Object
- Payload::DecoratorChain
- Includes:
- Enumerable
- Defined in:
- lib/payload/decorator_chain.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Collects a list of decorators to apply to a component within the context of a container.
Used internally by Container. Use Container#decorate.
Instance Method Summary collapse
- #==(other) ⇒ Object private
- #add(decorator) ⇒ Object private
- #decorate(base, container, *extra) ⇒ Object private
- #each(&block) ⇒ Object private
-
#initialize(decorators = []) ⇒ DecoratorChain
constructor
private
A new instance of DecoratorChain.
Constructor Details
#initialize(decorators = []) ⇒ DecoratorChain
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of DecoratorChain.
11 12 13 |
# File 'lib/payload/decorator_chain.rb', line 11 def initialize(decorators = []) @decorators = decorators end |
Instance Method Details
#==(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 |
# File 'lib/payload/decorator_chain.rb', line 29 def ==(other) other.is_a?(DecoratorChain) && decorators == other.decorators end |
#add(decorator) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/payload/decorator_chain.rb', line 15 def add(decorator) self.class.new decorators + [decorator] end |
#decorate(base, container, *extra) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 |
# File 'lib/payload/decorator_chain.rb', line 19 def decorate(base, container, *extra) decorators.inject(base) do |component, decorator| decorator.call(component, container, *extra) end end |
#each(&block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 |
# File 'lib/payload/decorator_chain.rb', line 25 def each(&block) decorators.each(&block) end |