Class: Statemachine::StubContext

Inherits:
Object
  • Object
show all
Defined in:
lib/statemachine/stub_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ StubContext

Returns a new instance of StubContext.



5
6
7
# File 'lib/statemachine/stub_context.rb', line 5

def initialize(options = {})
  @verbose = options[:verbose]
end

Instance Attribute Details

#statemachineObject

Returns the value of attribute statemachine.



9
10
11
# File 'lib/statemachine/stub_context.rb', line 9

def statemachine
  @statemachine
end

Instance Method Details

#__generic_method(name, *args) ⇒ Object



18
19
20
21
22
# File 'lib/statemachine/stub_context.rb', line 18

def __generic_method(name, *args)
  if !defined?($IS_TEST)
    puts "action invoked: #{name}(#{args.join(", ")}) #{block_given? ? "with block" : ""}" if @verbose
  end
end

#method(name) ⇒ Object



11
12
13
14
15
16
# File 'lib/statemachine/stub_context.rb', line 11

def method(name)
  super(name)
rescue
  self.class.class_eval "def #{name}(*args, &block); __generic_method(:#{name}, *args, &block); end"
  return super(name)
end