Class: Boxspring::Property
- Inherits:
-
Base
- Object
- ActiveHash::Base
- Base
- Boxspring::Property
show all
- Defined in:
- lib/boxspring/property.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Class Method Details
.find_by(parameters) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/boxspring/property.rb', line 5
def self.find_by( parameters )
parameters = parameters.stringify_keys.slice(
'code_name', 'domain_name'
)
parameters[ 'property_code' ] = parameters.delete( 'code_name' ) \
if parameters.include?( 'code_name' )
parameters[ 'property_domain_name' ] = parameters.delete( 'domain_name' ) \
if parameters.include?( 'domain_name' )
request = Request.new( parameters )
response = request.get( '/configuration' )
raise response.error if response.failure?
Property.new( response.content ).tap do | property |
property.instance_variable_set( '@api_interface', request )
end
end
|
Instance Method Details
#attribution_by_id(id) ⇒ Object
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/boxspring/property.rb', line 91
def attribution_by_id( id )
response = @api_interface.get( "/attributions/#{id}" )
if ( response.success? )
Attribution.new( response.content )
elsif ( response.code == '404' )
nil
else
raise response.error
end
end
|
#show_by_id(id) ⇒ Object
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/boxspring/property.rb', line 70
def show_by_id( id )
response = @api_interface.get( "/shows/#{id}" )
if ( response.success? )
Show.new( response.content )
elsif ( response.code == '404' )
nil
else
raise response.error
end
end
|
#shows ⇒ Object
81
82
83
84
85
86
87
88
89
|
# File 'lib/boxspring/property.rb', line 81
def shows
@_shows ||= begin
self.attributes.include?( :shows ) ?
self.attributes[ :shows ].map do | show |
Show.new( show )
end :
nil
end
end
|
#tag_by_id(id) ⇒ Object
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/boxspring/property.rb', line 59
def tag_by_id( id )
response = @api_interface.get( "/tags/#{id}" )
if ( response.success? )
Tag.new( response.content )
elsif ( response.code == '404' )
nil
else
raise response.error
end
end
|
#tag_collections(reload = false) ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/boxspring/property.rb', line 49
def tag_collections( reload = false )
@_tag_collections ||= begin
self.attributes.include?( :tag_collections ) ?
self.attributes[ :tag_collections ].map do | tag_collection |
TagCollection.new( tag_collection )
end :
nil
end
end
|
#theme ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/boxspring/property.rb', line 41
def theme
@_theme ||= begin
self.attributes.include?( :theme ) ?
Theme.new( self.attributes[ :theme ] ) :
nil
end
end
|
#video_by_id(id) ⇒ Object
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/boxspring/property.rb', line 115
def video_by_id( id )
response = @api_interface.get( "/videos/#{id}" )
if ( response.success? )
Video.new( response.content )
elsif ( response.code == '404' )
nil
else
raise response.error
end
end
|
#videos(parameters) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/boxspring/property.rb', line 102
def videos( parameters )
response = @api_interface.get( "/videos", parameters )
if ( response.success? )
response.content.map do | video |
Video.new( video )
end
elsif ( response.code == '404' )
nil
else
raise response.error
end
end
|