class Proforma::ExtendedEvaluator
This class provides robust functionality for value resolution and text templating. For value resolution it uses its own dot-notation and message-based object traversal algorithm. For text templating it uses the Stringento library.
Constants
- VERSION
Attributes
formatter[R]
resolver[R]
Public Class Methods
new(formatter: Formatter.new, resolver: Resolver.new)
click to toggle source
# File lib/proforma/extended_evaluator.rb, line 27 def initialize(formatter: Formatter.new, resolver: Resolver.new) raise ArgumentError, 'formatter is required' unless formatter raise ArgumentError, 'resolver is required' unless resolver @formatter = formatter @resolver = resolver freeze end
Public Instance Methods
text(object, expression)
click to toggle source
# File lib/proforma/extended_evaluator.rb, line 41 def text(object, expression) record = object.is_a?(Array) || object.nil? ? {} : object Stringento.evaluate( expression.to_s, record, resolver: resolver, formatter: formatter ) end
value(object, expression)
click to toggle source
# File lib/proforma/extended_evaluator.rb, line 37 def value(object, expression) resolver.resolve(expression, object) end