Class: Dry::Transformer::Composite Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/transformer/composite.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.

Composition of two functions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, right) ⇒ Composite

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 Composite.



20
21
22
23
# File 'lib/dry/transformer/composite.rb', line 20

def initialize(left, right)
  @left = left
  @right = right
end

Instance Attribute Details

#leftProc (readonly)

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:

  • (Proc)


12
13
14
# File 'lib/dry/transformer/composite.rb', line 12

def left
  @left
end

#rightProc (readonly)

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:

  • (Proc)


17
18
19
# File 'lib/dry/transformer/composite.rb', line 17

def right
  @right
end

Instance Method Details

#call(value) ⇒ Object Also known as: []

Call right side with the result from the left side

Parameters:

  • value (Object)

    The input value

Returns:

  • (Object)


32
33
34
# File 'lib/dry/transformer/composite.rb', line 32

def call(value)
  right.call(left.call(value))
end

#compose(other) ⇒ Object Also known as: +, >>

See Also:



40
41
42
# File 'lib/dry/transformer/composite.rb', line 40

def compose(other)
  self.class.new(self, other)
end

#to_astObject

See Also:



49
50
51
# File 'lib/dry/transformer/composite.rb', line 49

def to_ast
  left.to_ast << right.to_ast
end