Class: Reflekt::Control
- Inherits:
-
Reflection
- Object
- Reflection
- Reflekt::Control
- Defined in:
- lib/control.rb
Instance Attribute Summary
Attributes inherited from Reflection
Instance Method Summary collapse
-
#reflect(*args) ⇒ Object
Reflect on a method.
Methods inherited from Reflection
Constructor Details
This class inherits a constructor from Reflekt::Reflection
Instance Method Details
#reflect(*args) ⇒ Object
Reflect on a method.
Create a shadow action.
33 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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/control.rb', line 33 def reflect(*args) # Get trained rule sets. input_rule_sets = @aggregator.get_input_rule_sets(@klass, @method) output_rule_set = @aggregator.get_output_rule_set(@klass, @method) # Fail when no trained rule sets. if input_rule_sets.nil? @status = :fail π₯"> No trained rule sets", :fail, :reflect end # When arguments exist. unless args.size == 0 # Validate arguments against trained rule sets. unless input_rule_sets.nil? unless @aggregator.test_inputs(args, input_rule_sets) @status = :fail π₯"> Invalid inputs", @status, :reflect end end π₯"> Create meta for #{@method}(): #{args}", :info, :meta, @klass # TODO: Create metadata for other inputs such as instance variables. @inputs = MetaBuilder.create_many(args) end # Action method with real arguments. begin # Run reflection. output = @clone.send(@method, *args) @output = MetaBuilder.create(output) # Validate output with aggregated control rule sets. unless @aggregator.test_output(output, output_rule_set) @status = :fail π₯"> Invalid output", @status, :reflect end # When a system error occurs. rescue StandardError => @status = :error @message = # TODO: Write log entry to /reflections/errors.txt π₯"#{@method}() not reflected", :error, :control, @klass.class end end |