Class: GoodData::LCM2::SmartHash
- Inherits:
-
Hash
- Object
- Hash
- GoodData::LCM2::SmartHash
show all
- Defined in:
- lib/gooddata/lcm/lcm2.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *_args) ⇒ Object
32
33
34
|
# File 'lib/gooddata/lcm/lcm2.rb', line 32
def method_missing(name, *_args)
data(name)
end
|
Instance Method Details
#[](variable) ⇒ Object
36
37
38
|
# File 'lib/gooddata/lcm/lcm2.rb', line 36
def [](variable)
data(variable)
end
|
#check_specification(variable) ⇒ Object
48
49
50
51
52
53
|
# File 'lib/gooddata/lcm/lcm2.rb', line 48
def check_specification(variable)
if @specification && !@specification[variable.to_sym] && !@specification[variable.to_s] \
&& !@specification[variable.to_s.downcase.to_sym] && !@specification[variable.to_s.downcase]
fail "Param #{variable} is not defined in the specification"
end
end
|
#clear_filters ⇒ Object
40
41
42
|
# File 'lib/gooddata/lcm/lcm2.rb', line 40
def clear_filters
@specification = nil
end
|
#data(variable) ⇒ Object
55
56
57
58
|
# File 'lib/gooddata/lcm/lcm2.rb', line 55
def data(variable)
check_specification(variable)
fetch(keys.find { |k| k.to_s.downcase.to_sym == variable.to_s.downcase.to_sym }, nil)
end
|
#key?(key) ⇒ Boolean
60
61
62
63
64
65
66
67
68
|
# File 'lib/gooddata/lcm/lcm2.rb', line 60
def key?(key)
return true if super
keys.each do |k|
return true if k.to_s.downcase.to_sym == key.to_s.downcase.to_sym
end
false
end
|
#respond_to_missing?(name, *_args) ⇒ Boolean
70
71
72
73
|
# File 'lib/gooddata/lcm/lcm2.rb', line 70
def respond_to_missing?(name, *_args)
key = name.to_s.downcase.to_sym
key?(key)
end
|
#setup_filters(filter) ⇒ Object
44
45
46
|
# File 'lib/gooddata/lcm/lcm2.rb', line 44
def setup_filters(filter)
@specification = filter.to_hash
end
|