Class: SbrfMerchant::Utils::HighOrderFunctions::Compose
- Inherits:
-
Object
- Object
- SbrfMerchant::Utils::HighOrderFunctions::Compose
- Defined in:
- lib/sbrf_merchant/utils/high_order_functions/compose.rb
Overview
Обьединяем несколько callable сущностей в одну
Instance Attribute Summary collapse
-
#functions ⇒ Object
readonly
Returns the value of attribute functions.
Instance Method Summary collapse
- #call(arg) ⇒ Object
-
#initialize(*functions) ⇒ Compose
constructor
A new instance of Compose.
Constructor Details
#initialize(*functions) ⇒ Compose
Returns a new instance of Compose.
10 11 12 |
# File 'lib/sbrf_merchant/utils/high_order_functions/compose.rb', line 10 def initialize(*functions) @functions = functions end |
Instance Attribute Details
#functions ⇒ Object (readonly)
Returns the value of attribute functions.
8 9 10 |
# File 'lib/sbrf_merchant/utils/high_order_functions/compose.rb', line 8 def functions @functions end |
Instance Method Details
#call(arg) ⇒ Object
14 15 16 |
# File 'lib/sbrf_merchant/utils/high_order_functions/compose.rb', line 14 def call(arg) functions.inject(arg) { |acc, func| func.call(acc) } end |