class Payload::DecoratorChain
Collects a list of decorators to apply to a component within the context of a container.
Used internally by {Container}. Use {Container#decorate}.
@api private
Attributes
decorators[R]
Public Class Methods
new(decorators = [])
click to toggle source
# File lib/payload/decorator_chain.rb, line 11 def initialize(decorators = []) @decorators = decorators end
Public Instance Methods
==(other)
click to toggle source
# File lib/payload/decorator_chain.rb, line 29 def ==(other) other.is_a?(DecoratorChain) && decorators == other.decorators end
add(decorator)
click to toggle source
# File lib/payload/decorator_chain.rb, line 15 def add(decorator) self.class.new decorators + [decorator] end
decorate(base, container, *extra)
click to toggle source
# 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)
click to toggle source
# File lib/payload/decorator_chain.rb, line 25 def each(&block) decorators.each(&block) end