Class: Methodical::Modifier

Inherits:
SimpleDelegator
  • Object
show all
Includes:
Executable
Defined in:
lib/methodical/modifier.rb

Instance Attribute Summary

Attributes included from Executable

#raise_on_error

Instance Method Summary collapse

Methods included from Executable

#catch_disposition, #execute!, #raise_on_error?

Constructor Details

#initialize(name, action_item = nil, &block) ⇒ Modifier

Returns a new instance of Modifier.



8
9
10
11
12
# File 'lib/methodical/modifier.rb', line 8

def initialize(name, action_item=nil, &block)
  @name        = name
  __setobj__(action_item)
  @block       = block
end

Instance Method Details

#<<(rhs) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/methodical/modifier.rb', line 22

def <<(rhs)
  if self.action_item
    self.action_item << rhs
  else
    self.action_item = rhs
  end
  self
end

#call(baton = nil, raise_on_error = false) ⇒ Object



18
19
20
# File 'lib/methodical/modifier.rb', line 18

def call(baton=nil, raise_on_error=false)
  @block.call(action_item, baton)
end

#cloneObject



32
33
34
35
36
# File 'lib/methodical/modifier.rb', line 32

def clone
  the_clone = Object.instance_method(:clone).bind(self).call
  the_clone.__setobj__(__getobj__.clone)
  the_clone
end

#to_sObject



14
15
16
# File 'lib/methodical/modifier.rb', line 14

def to_s
  "<#{@name}>(#{action_item.to_s})"
end