Class: Overapp::TemplateFile::VarObj
- Includes:
- FromHash
- Defined in:
- lib/overapp/template_file/var_obj.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &b) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/overapp/template_file/var_obj.rb', line 7 def method_missing(sym,*args,&b) if file.vars.has_key?(sym) file.vars[sym] elsif file.vars.has_key?(sym.to_s) file.vars[sym.to_s] else raise "not found #{sym}, options are #{file.vars.inspect}" end end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
5 6 7 |
# File 'lib/overapp/template_file/var_obj.rb', line 5 def file @file end |
Instance Method Details
#render(body) ⇒ Object
17 18 19 20 21 |
# File 'lib/overapp/template_file/var_obj.rb', line 17 def render(body) require 'erb' erb = ERB.new(body) erb.result(binding) end |