Class: Control

Inherits:
Reflection show all
Defined in:
lib/Control.rb

Instance Attribute Summary

Attributes inherited from Reflection

#status

Instance Method Summary collapse

Methods inherited from Reflection

#initialize, #randomize, #serialize

Constructor Details

This class inherits a constructor from Reflection

Instance Method Details

#reflect(*args) ⇒ Object

Reflect on a method.

Creates a shadow execution.

Parameters:

  • *args (Dynamic)

    The method’s arguments.



32
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 32

def reflect(*args)

  # Get aggregated rule sets.
  input_rule_sets = @aggregator.get_input_rule_sets(@klass, @method)
  output_rule_set = @aggregator.get_output_rule_set(@klass, @method)

  # When arguments exist.
  unless args.size == 0

    # When aggregated rule sets exist.
    unless input_rule_sets.nil?

      # Validate arguments against aggregated rule sets.
      unless @aggregator.test_inputs(args, input_rule_sets)
        @status = :fail
      end

    end

    # Create metadata for each argument.
    # TODO: Create metadata for other inputs such as properties on the instance.
    @inputs = MetaBuilder.create_many(args)

  end

  # Action method with new/old arguments.
  begin

    # Run reflection.
    output = @clone.send(@method, *args)
    @output = MetaBuilder.create(output)

    # Validate output with aggregated control rule sets.
    unless output_rule_set.nil?
      unless @aggregator.test_output(output, output_rule_set)
        @status = :fail
      end
    end

  # When a system error occurs.
  rescue StandardError => message

    @status = :error
    @message = message

  end

end