Class: Funktional::StackRecorder

Inherits:
BlankSlate show all
Defined in:
lib/funktional/context/stack_recorder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ StackRecorder

Returns a new instance of StackRecorder.



9
10
11
12
# File 'lib/funktional/context/stack_recorder.rb', line 9

def initialize(target)
  @__target = target
  @__methods = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/funktional/context/stack_recorder.rb', line 26

def method_missing(method_name, *args, &block)
  @__methods << {
    :name => method_name,
    :args => args,
    :block => block
  }
  return self
end

Instance Attribute Details

#__targetObject (readonly)

Returns the value of attribute __target.



7
8
9
# File 'lib/funktional/context/stack_recorder.rb', line 7

def __target
  @__target
end

Instance Method Details

#__each_calledObject



18
19
20
# File 'lib/funktional/context/stack_recorder.rb', line 18

def __each_called
  @__methods.each { |meth| yield [meth[:name], meth[:args], meth[:block]] }
end

#__last_valueObject



22
23
24
# File 'lib/funktional/context/stack_recorder.rb', line 22

def __last_value
  @__methods.last[:args].first
end

#__meth(index) ⇒ Object



14
15
16
# File 'lib/funktional/context/stack_recorder.rb', line 14

def __meth(index)
  @__methods[index]
end