Class: Restfully::MediaType::ApplicationVndBonfireXml
Defined Under Namespace
Classes: Parser
Constant Summary
collapse
- NS =
"http://api.bonfire-project.eu/doc/schemas/occi"
- HIDDEN_TYPE_KEY =
"__type__"
Instance Attribute Summary
#io, #session
Instance Method Summary
collapse
default_type, defaults, #direct_fetch_uri, #initialize, #links, #meta, parent, parser, #property, serialize, set, signature, supports?, unserialize, #unserialized
Instance Method Details
#banner ⇒ Object
205
206
207
208
209
|
# File 'lib/restfully/media_type/application_vnd_bonfire_xml.rb', line 205
def banner
if property("name")
" name=#{property("name").inspect}"
end
end
|
#collection? ⇒ Boolean
9
10
11
|
# File 'lib/restfully/media_type/application_vnd_bonfire_xml.rb', line 9
def collection?
!!(property("items") && property("total") && property("offset"))
end
|
#complete? ⇒ Boolean
197
198
199
200
201
202
203
|
# File 'lib/restfully/media_type/application_vnd_bonfire_xml.rb', line 197
def complete?
if property.reject{|k,v| [HIDDEN_TYPE_KEY, "id", "name", "type"].include?(k)}.empty? && links.find(&:self?)
false
else
true
end
end
|
#each(*args, &block) ⇒ Object
212
213
214
215
216
217
|
# File 'lib/restfully/media_type/application_vnd_bonfire_xml.rb', line 212
def each(*args, &block)
@items ||= (property("items") || []).map{|i|
self.class.new(self.class.serialize(i), @session)
}
@items.each(*args, &block)
end
|
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/restfully/media_type/application_vnd_bonfire_xml.rb', line 181
def
(property.delete("link") || []).map do |link|
l = Link.new(
:rel => link['rel'],
:type => link['type'] || self.class.default_type,
:href => link['href'],
:title => link["title"],
:id => link["title"]
)
end
end
|
#represents?(id) ⇒ Boolean
193
194
195
|
# File 'lib/restfully/media_type/application_vnd_bonfire_xml.rb', line 193
def represents?(id)
property("id") == id.to_s || property("name") == id.to_s || links.find{|l| l.self? && l.href.to_s.split("/").last == id.to_s}
end
|