Class: BurstStruct::Burst
- Inherits:
-
Object
- Object
- BurstStruct::Burst
show all
- Defined in:
- lib/yelp/burst_struct.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(hash = {}) ⇒ Burst
Returns a new instance of Burst.
3
4
5
|
# File 'lib/yelp/burst_struct.rb', line 3
def initialize(hash = {})
@hash = hash
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object
7
8
9
10
11
12
13
14
15
|
# File 'lib/yelp/burst_struct.rb', line 7
def method_missing(method_name, *arguments, &block)
key = find_key(method_name)
if key
return_or_build_struct(key)
else
super
end
end
|
Class Method Details
.convert_array(array) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/yelp/burst_struct.rb', line 21
def self.convert_array(array)
array.map do |item|
case item
when Hash
Burst.new(item)
when Array
Burst.convert_array(item)
else
item
end
end
end
|
Instance Method Details
#respond_to?(method_name, include_private = false) ⇒ Boolean
17
18
19
|
# File 'lib/yelp/burst_struct.rb', line 17
def respond_to?(method_name, include_private = false)
@hash.keys.include?(method_name) || super
end
|
#to_json(options = {}) ⇒ Object
34
35
36
|
# File 'lib/yelp/burst_struct.rb', line 34
def to_json(options = {})
JSON.generate(@hash)
end
|