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
Instance Method Summary
collapse
#_P, #_decode_params, #_p, #captured_as, #echo, #import, #start_capture, #stop_capture
Constructor Details
#initialize(vars = nil) ⇒ BaseContext
Returns a new instance of BaseContext.
231
232
233
|
# File 'lib/tenjin.rb', line 231
def initialize(vars=nil)
update(vars) if vars.is_a?(Hash)
end
|
Instance Method Details
#[](key) ⇒ Object
235
236
237
|
# File 'lib/tenjin.rb', line 235
def [](key)
instance_variable_get("@#{key}")
end
|
#[]=(key, val) ⇒ Object
239
240
241
|
# File 'lib/tenjin.rb', line 239
def []=(key, val)
instance_variable_set("@#{key}", val)
end
|
#each ⇒ Object
257
258
259
260
261
262
263
|
# File 'lib/tenjin.rb', line 257
def each()
instance_variables().each do |name|
val = instance_variable_get(name)
key = name[1..-1]
yield([key, val]) if name != '@_buf' && name != '@_engine'
end
end
|
#escape(val) ⇒ Object
243
244
245
|
# File 'lib/tenjin.rb', line 243
def escape(val)
return val
end
|
#key?(key) ⇒ Boolean
253
254
255
|
# File 'lib/tenjin.rb', line 253
def key?(key)
return self.instance_variables.include?("@#{key}")
end
|
#update(hash) ⇒ Object
247
248
249
250
251
|
# File 'lib/tenjin.rb', line 247
def update(hash)
hash.each do |key, val|
self[key] = val
end
end
|