Class: TableStructure::Utils::CompositeCallable
- Inherits:
-
Object
- Object
- TableStructure::Utils::CompositeCallable
- Defined in:
- lib/table_structure/utils.rb
Instance Method Summary collapse
- #call(source) ⇒ Object
- #compose(*callables) ⇒ Object
-
#initialize ⇒ CompositeCallable
constructor
A new instance of CompositeCallable.
Constructor Details
#initialize ⇒ CompositeCallable
Returns a new instance of CompositeCallable.
26 27 28 |
# File 'lib/table_structure/utils.rb', line 26 def initialize @callables = [] end |
Instance Method Details
#call(source) ⇒ Object
35 36 37 |
# File 'lib/table_structure/utils.rb', line 35 def call(source) @callables.reduce(source) { |memo, callable| callable.call(memo) } end |
#compose(*callables) ⇒ Object
30 31 32 33 |
# File 'lib/table_structure/utils.rb', line 30 def compose(*callables) @callables.concat(callables.flatten.compact) self end |