Class: Restfully::MediaType::Grid5000
Instance Attribute Summary
#io, #session
Instance Method Summary
collapse
#banner, #complete?, default_type, defaults, #initialize, #links, parent, parser, #property, serialize, set, signature, supports?, unserialize, #unserialized
Instance Method Details
#collection? ⇒ Boolean
45
46
47
|
# File 'lib/restfully/media_type/grid5000.rb', line 45
def collection?
!!(property("items") && property("total") && property("offset"))
end
|
#each(*args, &block) ⇒ Object
63
64
65
66
67
|
# File 'lib/restfully/media_type/grid5000.rb', line 63
def each(*args, &block)
(property("items") || []).map{|i|
self.class.new(self.class.serialize(i), @session)
}.each(*args, &block)
end
|
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/restfully/media_type/grid5000.rb', line 33
def
(property.delete("links") || []).map do |link|
l = Link.new(
:rel => link['rel'],
:type => link['type'],
:href => link['href'],
:title => link["title"],
:id => link["title"]
)
end
end
|
49
50
51
52
53
54
55
|
# File 'lib/restfully/media_type/grid5000.rb', line 49
def meta
if collection?
property("items")
else
property
end
end
|
#represents?(id) ⇒ Boolean
57
58
59
60
|
# File 'lib/restfully/media_type/grid5000.rb', line 57
def represents?(id)
id = id.to_s
property("uid") == id || property("uid") == id.to_i
end
|