Class: Localite::Template::Env
- Inherits:
-
Object
- Object
- Localite::Template::Env
- Defined in:
- lib/localite/template.rb
Overview
the environment during run
Defined Under Namespace
Modules: Helpers
Instance Method Summary collapse
- #[](code) ⇒ Object
-
#initialize(host) ⇒ Env
constructor
A new instance of Env.
- #method_missing(sym, *args, &block) ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/localite/template.rb', line 46 def method_missing(sym, *args, &block) unless @host.is_a?(Hash) return @host.send(sym, *args, &block) end begin return @host.fetch(sym.to_sym) rescue IndexError :void end begin return @host.fetch(sym.to_s) rescue IndexError :void end super end |
Instance Method Details
#[](code) ⇒ Object
71 72 73 |
# File 'lib/localite/template.rb', line 71 def [](code) eval(code).to_s end |