Class: Axiom::Evaluator::Context
Overview
Provide a context to evaluate a Relation operation block
Instance Attribute Summary collapse
-
#functions ⇒ Hash
readonly
private
The functions to evaluate.
-
#yield ⇒ Object
readonly
private
Return the block results.
Instance Method Summary collapse
-
#[](name) ⇒ Attribute
Lookup the attribute in the header.
-
#add(attribute, object = Undefined) { ... } ⇒ self
Add a function to be evaluated by the summarization operation.
-
#initialize(header) ⇒ undefined
constructor
private
Initialize a Context.
-
#respond_to?(name) ⇒ Boolean
private
Test if the method is supported on this object.
-
#send(*args, &block) ⇒ Object
private
Forward a message to the object.
Methods included from Aliasable
Constructor Details
#initialize(header) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a Context
33 34 35 36 37 38 |
# File 'lib/axiom/support/evaluator.rb', line 33 def initialize(header) @header = header @functions = ::Hash.new @yield = yield self @functions.freeze end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Attribute (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Lookup the attribute in the header using the attribute name
114 115 116 117 118 |
# File 'lib/axiom/support/evaluator.rb', line 114 def method_missing(name, *args) super unless respond_to?(name) ::Kernel.raise ::ArgumentError, "wrong number of arguments (#{args.length} for 0)" unless args.empty? self[name] end |
Instance Attribute Details
#functions ⇒ Hash (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The functions to evaluate
17 18 19 |
# File 'lib/axiom/support/evaluator.rb', line 17 def functions @functions end |
#yield ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the block results
24 25 26 |
# File 'lib/axiom/support/evaluator.rb', line 24 def yield @yield end |
Instance Method Details
#[](name) ⇒ Attribute
Lookup the attribute in the header
76 77 78 |
# File 'lib/axiom/support/evaluator.rb', line 76 def [](name) @header[name] end |
#add(attribute, object = Undefined) { ... } ⇒ self
Add a function to be evaluated by the summarization operation
59 60 61 62 63 64 |
# File 'lib/axiom/support/evaluator.rb', line 59 def add(attribute, object = Undefined, &block) object = block if object.equal?(Undefined) type = Attribute.infer_type(object) functions[type.coerce(attribute)] = object self end |
#respond_to?(name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Test if the method is supported on this object
87 88 89 |
# File 'lib/axiom/support/evaluator.rb', line 87 def respond_to?(name, *) @header.any? { |attribute| attribute.name.equal?(name) } end |
#send(*args, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Forward a message to the object
98 99 100 |
# File 'lib/axiom/support/evaluator.rb', line 98 def send(*args, &block) __send__(*args, &block) end |