Class: Action

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

Overview

A shadow action.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(caller_object, method, reflect_amount, stack) ⇒ Action

Create Action.

Parameters:

  • object (Object)

    The calling object.

  • method (Symbol)

    The calling method.

  • reflect_amount (Integer)

    The number of experiments to create per action.

  • stack (ActionStack)

    The shadow action call stack.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/action.rb', line 34

def initialize(caller_object, method, reflect_amount, stack)

  @time = Time.now.to_i
  @unique_id = @time + rand(1..99999)
  @base = nil
  @parent = nil
  @child = nil

  # Dependency.
  @stack = stack

  # Caller.
  @caller_object = caller_object
  @caller_id = caller_object.object_id
  @caller_class = caller_object.class
  @klass = @caller_class.to_s.to_sym
  @method = method

  # Reflections.
  @control = nil
  @experiments = Array.new(reflect_amount)

  # State.
  if @stack.peek() == nil
    @is_base = true
  else
    @is_base = false
    @base = @stack.base()
  end
  @is_reflecting = false

end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



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

def base
  @base
end

#caller_classObject

Returns the value of attribute caller_class.



15
16
17
# File 'lib/action.rb', line 15

def caller_class
  @caller_class
end

#caller_idObject

Returns the value of attribute caller_id.



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

def caller_id
  @caller_id
end

#caller_objectObject

Returns the value of attribute caller_object.



13
14
15
# File 'lib/action.rb', line 13

def caller_object
  @caller_object
end

#childObject

Returns the value of attribute child.



20
21
22
# File 'lib/action.rb', line 20

def child
  @child
end

#controlObject

Returns the value of attribute control.



21
22
23
# File 'lib/action.rb', line 21

def control
  @control
end

#experimentsObject

Returns the value of attribute experiments.



22
23
24
# File 'lib/action.rb', line 22

def experiments
  @experiments
end

#is_baseObject

Returns the value of attribute is_base.



24
25
26
# File 'lib/action.rb', line 24

def is_base
  @is_base
end

#is_reflectingObject

Returns the value of attribute is_reflecting.



23
24
25
# File 'lib/action.rb', line 23

def is_reflecting
  @is_reflecting
end

#klassObject

Returns the value of attribute klass.



16
17
18
# File 'lib/action.rb', line 16

def klass
  @klass
end

#methodObject

Returns the value of attribute method.



17
18
19
# File 'lib/action.rb', line 17

def method
  @method
end

#parentObject

Returns the value of attribute parent.



19
20
21
# File 'lib/action.rb', line 19

def parent
  @parent
end

#unique_idObject

Returns the value of attribute unique_id.



12
13
14
# File 'lib/action.rb', line 12

def unique_id
  @unique_id
end

Instance Method Details

#has_empty_experiments?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/action.rb', line 67

def has_empty_experiments?
  @experiments.include? nil
end

#has_finished_reflecting?Boolean

Returns:

  • (Boolean)


78
79
80
81
82
83
84
85
86
# File 'lib/action.rb', line 78

def has_finished_reflecting?
  if is_reflecting?
    return false
  end
  if has_empty_experiments?
    return false
  end
  return true
end

#is_reflecting?Boolean

Is the Action currently reflecting methods?

Returns:

  • (Boolean)


74
75
76
# File 'lib/action.rb', line 74

def is_reflecting?
  @is_reflecting
end