Class: Tenjin::BaseContext
- Inherits:
-
Object
- Object
- Tenjin::BaseContext
show all
- Includes:
- Enumerable, ContextHelper
- Defined in:
- lib/tenjin.rb
Overview
base class for Context class
Instance Attribute Summary
#_buf, #_engine, #_layout, #_template
Instance Method Summary
collapse
#_P, #_decode_params, #_p, #cache_with, #captured_as, #echo, #escape, #import, #start_capture, #stop_capture
Constructor Details
#initialize(vars = nil) ⇒ BaseContext
Returns a new instance of BaseContext.
401
402
403
|
# File 'lib/tenjin.rb', line 401
def initialize(vars=nil)
update(vars) if vars.is_a?(Hash)
end
|
Instance Method Details
#[](key) ⇒ Object
405
406
407
|
# File 'lib/tenjin.rb', line 405
def [](key)
instance_variable_get("@#{key}")
end
|
#[]=(key, val) ⇒ Object
409
410
411
|
# File 'lib/tenjin.rb', line 409
def []=(key, val)
instance_variable_set("@#{key}", val)
end
|
#each ⇒ Object
430
431
432
433
434
435
436
437
438
|
# File 'lib/tenjin.rb', line 430
def each()
instance_variables().each do |name|
if name != '@_buf' && name != '@_engine'
val = instance_variable_get(name)
key = name[1..-1]
yield([key, val])
end
end
end
|
#key?(key) ⇒ Boolean
Also known as:
has_key?
419
420
421
|
# File 'lib/tenjin.rb', line 419
def key?(key)
return self.instance_variables.include?("@#{key}")
end
|
#update(hash) ⇒ Object
413
414
415
416
417
|
# File 'lib/tenjin.rb', line 413
def update(hash)
hash.each do |key, val|
self[key] = val
end
end
|