Class: Fortitude::MethodTemplates::SimpleCompiledTemplate::EvaluationObject

Inherits:
Object
  • Object
show all
Defined in:
lib/fortitude/method_templates/simple_compiled_template.rb

Instance Method Summary collapse

Constructor Details

#initializeEvaluationObject

Returns a new instance of EvaluationObject.


63
64
65
# File 'lib/fortitude/method_templates/simple_compiled_template.rb', line 63

def initialize
  @hash = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object


81
82
83
84
# File 'lib/fortitude/method_templates/simple_compiled_template.rb', line 81

def method_missing(name, *args)
  define_hash_method!(name)
  send(name, *args)
end

Instance Method Details

#define_hash_method!(name) ⇒ Object


71
72
73
74
75
76
77
78
79
# File 'lib/fortitude/method_templates/simple_compiled_template.rb', line 71

def define_hash_method!(name)
  symbol_name = name.to_sym
  string_name = name.to_s

  metaclass = (class << self; self; end)
  metaclass.send(:define_method, name) do
    @hash[symbol_name]
  end
end

#hash=(h) ⇒ Object


67
68
69
# File 'lib/fortitude/method_templates/simple_compiled_template.rb', line 67

def hash=(h)
  @hash = h.symbolize_keys
end