Class: Delayer::Deferred::Deferredable::NodeSequence::Sequence

Inherits:
Object
  • Object
show all
Defined in:
lib/delayer/deferred/deferredable/node_sequence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Sequence

Returns a new instance of Sequence.



11
12
13
14
15
# File 'lib/delayer/deferred/deferredable/node_sequence.rb', line 11

def initialize(name)
  @name = name.to_sym
  @map = {}
  @exceptions = Hash.new(Delayer::Deferred::SequenceError)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/delayer/deferred/deferredable/node_sequence.rb', line 9

def name
  @name
end

Instance Method Details

#add(seq, flow = seq.name) ⇒ Object



17
18
19
20
# File 'lib/delayer/deferred/deferredable/node_sequence.rb', line 17

def add(seq, flow = seq.name)
  @map[flow] = seq
  self
end

#exception(exc, flow) ⇒ Object



22
23
24
25
# File 'lib/delayer/deferred/deferredable/node_sequence.rb', line 22

def exception(exc, flow)
  @exceptions[flow] = exc
  self
end

#inspectObject



35
36
37
# File 'lib/delayer/deferred/deferredable/node_sequence.rb', line 35

def inspect
  "#<#{self.class}: #{name}>"
end

#pull(flow) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/delayer/deferred/deferredable/node_sequence.rb', line 27

def pull(flow)
  if @map.has_key?(flow.to_sym)
    @map[flow.to_sym]
  else
    raise @exceptions[flow.to_sym], "Invalid sequence flow `#{name}' to `#{flow}'."
  end
end