Class: HashWrapper
- Inherits:
-
Object
show all
- Includes:
- FromHash
- Defined in:
- lib/formula_eval/wrapper.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &b) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/formula_eval/wrapper.rb', line 18
def method_missing(sym,*args,&b)
if obj.keys.include?(sym.to_s)
self[sym.to_s]
else
super
end
end
|
Instance Attribute Details
Returns the value of attribute hash.
16
17
18
|
# File 'lib/formula_eval/wrapper.rb', line 16
def hash
@hash
end
|
Instance Method Details
25
26
27
28
29
30
31
|
# File 'lib/formula_eval/wrapper.rb', line 25
def [](x)
raise 'dot_set' if x.to_s == 'dot_set'
res = hash[x.to_s]
res = nil if res.blank?
res.to_wrapped
end
|
#[]=(k, v) ⇒ Object
32
33
34
|
# File 'lib/formula_eval/wrapper.rb', line 32
def []=(k,v)
obj[k.to_s] = v
end
|
#delete(k) ⇒ Object
45
46
47
|
# File 'lib/formula_eval/wrapper.rb', line 45
def delete(k)
obj.delete(k)
end
|
52
53
54
|
# File 'lib/formula_eval/wrapper.rb', line 52
def keys
obj.keys
end
|
#kind_of?(x) ⇒ Boolean
48
49
50
51
|
# File 'lib/formula_eval/wrapper.rb', line 48
def kind_of?(x)
return true if x == Hash
super
end
|
35
|
# File 'lib/formula_eval/wrapper.rb', line 35
def obj; hash; end
|
#respond_to?(sym) ⇒ Boolean
42
43
44
|
# File 'lib/formula_eval/wrapper.rb', line 42
def respond_to?(sym)
obj.keys.include?(sym.to_s)
end
|
#to_unwrapped ⇒ Object
39
40
41
|
# File 'lib/formula_eval/wrapper.rb', line 39
def to_unwrapped
hash.to_unwrapped
end
|
#to_wrapped ⇒ Object
36
37
38
|
# File 'lib/formula_eval/wrapper.rb', line 36
def to_wrapped
self
end
|