class Reflekt::Reflection
Attributes
status[R]
Public Class Methods
new(action, number, aggregator)
click to toggle source
Create a reflection.
@param action [Action] The Action
that created this Reflection
. @param number [Integer] Multiple Reflections can be created per Action
. @param aggregator [RuleSetAggregator] The aggregated RuleSet
for this class/method.
# 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
Public Instance Methods
reflect(*args)
click to toggle source
Reflect on a method.
Create a shadow action. @param *args [Dynamic] The method's arguments.
# File lib/reflection.rb, line 68 def reflect(*args) # Implemented by Control and Experiment. end
serialize()
click to toggle source
Get the results of the reflection.
@keys
- eid [Integer] Execution ID - aid [Integer] Action ID - rid [Integer] Reflection ID - num [Integer] Reflection number
@return [Hash] Reflection
metadata.
# 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 |meta| meta.nil? ? nil : reflection[:inputs] << meta.serialize() end end unless @output.nil? reflection[:output] = @output.serialize() end return reflection end