Class: Reflekt::Reflection
Direct Known Subclasses
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(action, number, aggregator) ⇒ Reflection
constructor
Create a reflection.
-
#reflect(*args) ⇒ Object
Reflect on a method.
-
#serialize ⇒ Hash
Get the results of the reflection.
Constructor Details
#initialize(action, number, aggregator) ⇒ Reflection
Create a reflection.
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 |
# File 'lib/reflection.rb', line 36 def initialize(action, number, aggregator) @action = action @reflection_id = action.unique_id + number @number = number # Dependency. @aggregator = aggregator # Caller. @klass = action.klass @method = action.method # Metadata. @inputs = nil @output = nil # Clone the action's calling object. # TODO: Abstract away into Clone class. @clone = action.caller_object.clone # Result. @status = :pass @time = Time.now.to_i @message = nil end |
Instance Attribute Details
#status ⇒ Object (readonly)
Returns the value of attribute status.
27 28 29 |
# File 'lib/reflection.rb', line 27 def status @status end |
Instance Method Details
#reflect(*args) ⇒ Object
Reflect on a method.
Create a shadow action.
68 69 70 |
# File 'lib/reflection.rb', line 68 def reflect(*args) # Implemented by Control and Experiment. end |
#serialize ⇒ Hash
Get the results of the reflection.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/reflection.rb', line 83 def serialize() # Create execution ID from the ID of the first action in the ActionStack. execution_id = @action.unique_id unless @action.base.nil? execution_id = @action.base.unique_id end # Build reflection. reflection = { :eid => execution_id, :aid => @action.unique_id, :rid => @reflection_id, :num => @number, :time => @time, :class => @klass, :method => @method, :status => @status, :message => @message, :inputs => nil, :output => nil, } # TODO: After the last experiment for an action is completed, serialize() # appears to be called twice. Possibly due to inheritance. 🔥"> Save meta for #{@method}()", :save, :meta, @klass unless @inputs.nil? reflection[:inputs] = [] @inputs.each do || .nil? ? nil : reflection[:inputs] << .serialize() end end unless @output.nil? reflection[:output] = @output.serialize() end return reflection end |