class Proforma::HashEvaluator

This class will serve as the evaluator that gets shipped with the base framework. Other packages can extend or create their own and plug them into the rendering pipeline. This, being a prototype for customizable evaluators, just provides basic evaluation:

Constants

PROPERTY_PREFIX

Public Instance Methods

text(object, expression) click to toggle source
# File lib/proforma/hash_evaluator.rb, line 28
def text(object, expression)
  if expression.to_s.start_with?(PROPERTY_PREFIX)
    value(object, expression.to_s[PROPERTY_PREFIX.length..-1])
  else
    expression
  end
end
value(object, expression) click to toggle source
# File lib/proforma/hash_evaluator.rb, line 21
def value(object, expression)
  return object if expression.to_s.empty?
  return nil    unless object.is_a?(Hash)

  object[expression.to_s] || object[expression.to_s.to_sym]
end