Class: CallSheet::Step Private

Inherits:
Object
  • Object
show all
Includes:
Deterministic::Prelude::Result, Wisper::Publisher
Defined in:
lib/call_sheet/step.rb

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step_name, operation, call_args = []) ⇒ Step

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



14
15
16
17
18
# File 'lib/call_sheet/step.rb', line 14

def initialize(step_name, operation, call_args = [])
  @step_name = step_name
  @operation = operation
  @call_args = call_args
end

Instance Attribute Details

#call_argsObject (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.



12
13
14
# File 'lib/call_sheet/step.rb', line 12

def call_args
  @call_args
end

#operationObject (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.



11
12
13
# File 'lib/call_sheet/step.rb', line 11

def operation
  @operation
end

#step_nameObject (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.



10
11
12
# File 'lib/call_sheet/step.rb', line 10

def step_name
  @step_name
end

Instance Method Details

#arityObject

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.



37
38
39
# File 'lib/call_sheet/step.rb', line 37

def arity
  operation.arity
end

#call(input) ⇒ Object

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.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/call_sheet/step.rb', line 24

def call(input)
  args = (call_args << input)
  result = operation.call(*args)

  result.map { |value|
    broadcast :"#{step_name}_success", value
    Success(value)
  }.map_err { |value|
    broadcast :"#{step_name}_failure", *args, value
    Failure(StepFailure.new(step_name, value))
  }
end

#with_call_args(*call_args) ⇒ Object

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.



20
21
22
# File 'lib/call_sheet/step.rb', line 20

def with_call_args(*call_args)
  self.class.new(step_name, operation, call_args)
end