Class: ContextHolder
- Inherits:
-
Struct
- Object
- Struct
- ContextHolder
- Defined in:
- lib/thymeleaf/context/context_holder.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#parent_context ⇒ Object
Returns the value of attribute parent_context.
Instance Method Summary collapse
- #evaluate(expr) ⇒ Object
-
#initialize(context, parent_context = nil) ⇒ ContextHolder
constructor
A new instance of ContextHolder.
- #method_missing(m, *args) ⇒ Object
- #root ⇒ Object
Constructor Details
#initialize(context, parent_context = nil) ⇒ ContextHolder
Returns a new instance of ContextHolder.
6 7 8 9 10 11 12 |
# File 'lib/thymeleaf/context/context_holder.rb', line 6 def initialize(context, parent_context = nil) if context.is_a? Hash super(ContextStruct.new(context), parent_context) else super(context, parent_context) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/thymeleaf/context/context_holder.rb', line 18 def method_missing(m, *args) if context.respond_to? m context.send(m, *args) elsif !parent_context.nil? parent_context.send(m, *args) end end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context
4 5 6 |
# File 'lib/thymeleaf/context/context_holder.rb', line 4 def context @context end |
#parent_context ⇒ Object
Returns the value of attribute parent_context
4 5 6 |
# File 'lib/thymeleaf/context/context_holder.rb', line 4 def parent_context @parent_context end |
Instance Method Details
#evaluate(expr) ⇒ Object
14 15 16 |
# File 'lib/thymeleaf/context/context_holder.rb', line 14 def evaluate(expr) instance_eval(expr.to_s) end |
#root ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/thymeleaf/context/context_holder.rb', line 26 def root if parent_context.nil? context else parent_context.root end end |