Class: FEEL::QualifiedName
- Defined in:
- lib/feel/nodes.rb
Overview
-
qualified name = name , { “.” , name } ;
Instance Method Summary collapse
-
#context_get(context, key, root: :nil) ⇒ Object
Get a key from the context, using symbol/string lookup, with errors if need be, and optionally overriding the root object for full path during errors.
- #eval(context = {}) ⇒ Object
Methods inherited from Node
#access_property, #qualified_names_in_context, #raise_evaluation_error
Instance Method Details
#context_get(context, key, root: :nil) ⇒ Object
Get a key from the context, using symbol/string lookup, with errors if need be, and optionally overriding the root object for full path during errors.
297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/feel/nodes.rb', line 297 def context_get(context, key, root: :nil) root = context if root == :nil if context.key?(key.to_sym) context[key.to_sym] elsif context.key?(key) context[key] else raise_evaluation_error(head.text_value + tail.text_value, root) if FEEL.config.strict nil end end |
#eval(context = {}) ⇒ Object
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/feel/nodes.rb', line 272 def eval(context = {}) head_name = head.eval(context) if tail.empty? context_get(context, head_name) else initial_value = context_get(context, head_name) # Process each segment in the tail, evaluating names to handle backticks tail.elements.inject(initial_value) do |value, element| return nil unless value key = element.name.eval(context) if value.respond_to?(:key?) context_get(value, key, root: context) else access_property(value, key) end end end end |