Class: Pipetree::Flow::StepMap

Inherits:
Object
  • Object
show all
Defined in:
lib/pipetree/flow/step_map.rb

Overview

Map original proc or its name to the wrapped On. This class is solely dedicated for inspect and insert operations, and not involved at run-time at all.

Instance Method Summary collapse

Constructor Details

#initializeStepMap

Returns a new instance of StepMap.



5
6
7
# File 'lib/pipetree/flow/step_map.rb', line 5

def initialize
  @hash = {}
end

Instance Method Details

#[](key) ⇒ Object



13
14
15
# File 'lib/pipetree/flow/step_map.rb', line 13

def [](key)
  @hash[key]
end

#[]=(step, name, original_proc, operator) ⇒ Object



9
10
11
# File 'lib/pipetree/flow/step_map.rb', line 9

def []=(step, (name, original_proc, operator))
  @hash[step] = Pipetree::Flow::Inspect::Proc.new(name, original_proc, operator)
end

#find_proc(original_proc) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/pipetree/flow/step_map.rb', line 17

def find_proc(original_proc)
  method = original_proc.is_a?(String) ? :name : :proc

  @hash.find do |step, inspect_proc|
    inspect_proc.send(method) == original_proc and return step
  end
end