Class: SbrfMerchant::Utils::HighOrderFunctions::Compose

Inherits:
Object
  • Object
show all
Defined in:
lib/sbrf_merchant/utils/high_order_functions/compose.rb

Overview

Обьединяем несколько callable сущностей в одну

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#functionsObject (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