Class: Streak::StreakObject
- Inherits:
-
Object
- Object
- Streak::StreakObject
show all
- Defined in:
- lib/streak/streak_object.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of StreakObject.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/streak/streak_object.rb', line 36
def method_missing(name, *args)
if @values.has_key?(name)
@values[name]
else
super
end
end
|
Class Method Details
.attributes ⇒ Object
16
17
18
|
# File 'lib/streak/streak_object.rb', line 16
def self.attributes
[]
end
|
.construct_from(values) ⇒ Object
24
25
26
|
# File 'lib/streak/streak_object.rb', line 24
def self.construct_from(values)
object = self.new(values)
end
|
.convert_to_streak_object(resp, type = nil, relation = nil) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/streak/streak_object.rb', line 4
def self.convert_to_streak_object(resp, type = nil, relation = nil)
case resp
when Array
resp.map { |r| convert_to_streak_object(r, type, relation) }
when Hash
object_class = (relation.nil? ? type : type.relations[relation]) || StreakObject
object_class.construct_from(resp)
else
resp
end
end
|
.relations ⇒ Object
20
21
22
|
# File 'lib/streak/streak_object.rb', line 20
def self.relations
{}
end
|