Class: StateFlow::Context::Manipulation

Inherits:
Object
  • Object
show all
Defined in:
lib/state_flow/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, target, method, *args, &block) ⇒ Manipulation

Returns a new instance of Manipulation.



122
123
124
125
126
# File 'lib/state_flow/context.rb', line 122

def initialize(context, target, method, *args, &block)
  @context = context
  @target, @method, @args, @block = target, method, args, block
  @trace = caller(3)
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



119
120
121
# File 'lib/state_flow/context.rb', line 119

def args
  @args
end

#blockObject (readonly)

Returns the value of attribute block.



119
120
121
# File 'lib/state_flow/context.rb', line 119

def block
  @block
end

#contextObject (readonly)

Returns the value of attribute context.



121
122
123
# File 'lib/state_flow/context.rb', line 121

def context
  @context
end

#methodObject (readonly)

Returns the value of attribute method.



119
120
121
# File 'lib/state_flow/context.rb', line 119

def method
  @method
end

#resultObject (readonly)

Returns the value of attribute result.



120
121
122
# File 'lib/state_flow/context.rb', line 120

def result
  @result
end

#targetObject (readonly)

Returns the value of attribute target.



119
120
121
# File 'lib/state_flow/context.rb', line 119

def target
  @target
end

#traceObject (readonly)

Returns the value of attribute trace.



120
121
122
# File 'lib/state_flow/context.rb', line 120

def trace
  @trace
end

Instance Method Details

#executeObject



128
129
130
131
132
133
134
# File 'lib/state_flow/context.rb', line 128

def execute
  begin
    return @result = @target.send(@method, *@args, &@block)
  rescue Exception
    raise unless @context.force_recovering?
  end
end

#inspectObject



136
137
138
139
140
141
142
# File 'lib/state_flow/context.rb', line 136

def inspect
  args_part = @args.inspect.gsub(/^\[|\]$/, '')
  if !args_part.nil? && !args_part.empty?
    args_part = "(#{args_part})"
  end
  "#{@target.class.name}##{@method}#{args_part}#{@block ? " with block" : nil}"
end