Class: WEEL::ReadHash
- Inherits:
-
Object
- Object
- WEEL::ReadHash
- Defined in:
- lib/weel.rb
Overview
}}}
Instance Method Summary collapse
-
#initialize(values) ⇒ ReadHash
constructor
{{{.
- #method_missing(name, *args) ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(values) ⇒ ReadHash
{{{
268 269 270 |
# File 'lib/weel.rb', line 268 def initialize(values) @__weel_values = values end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/weel.rb', line 276 def method_missing(name,*args) if args.empty? && @__weel_values.key?(name) @__weel_values[name] elsif args.empty? && @__weel_values.key?(name.to_s) @__weel_values[name.to_s] elsif name.to_s[-1..-1] == "=" && args.length == 1 temp = name.to_s[0..-2] @__weel_values[temp.to_sym] = args[0] elsif name.to_s == "[]=" && args.length == 2 @__weel_values[args[0]] = args[1] elsif name.to_s == "[]" && args.length == 1 @__weel_values[args[0]] else nil end end |
Instance Method Details
#to_json(*args) ⇒ Object
272 273 274 |
# File 'lib/weel.rb', line 272 def to_json(*args) @__weel_values.to_json(*args) end |