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
|
#direct_fetch_uri(symbol) ⇒ Object
49
50
51
52
53
|
# File 'lib/restfully/media_type/grid5000.rb', line 49
def direct_fetch_uri(symbol)
self_link = links.find{|l| l.self?}
return nil if self_link.nil?
URI.parse([self_link.href, symbol.to_s].join("/"))
end
|
#each(*args, &block) ⇒ Object
69
70
71
72
73
|
# File 'lib/restfully/media_type/grid5000.rb', line 69
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
|
55
56
57
58
59
60
61
|
# File 'lib/restfully/media_type/grid5000.rb', line 55
def meta
if collection?
property("items")
else
property
end
end
|
#represents?(id) ⇒ Boolean
63
64
65
66
|
# File 'lib/restfully/media_type/grid5000.rb', line 63
def represents?(id)
id = id.to_s
property("uid") == id || property("uid") == id.to_i
end
|