Class: GoodData::Links
Instance Attribute Summary collapse
Attributes inherited from Rest::Object
#client, #json, #project
Instance Method Summary
collapse
#obj_id
client, default_client, #saved?
#data_property_reader
#data_property_writer
#metadata_property_reader
#metadata_property_writer
#meta
#root_key
#content
Constructor Details
#initialize(items) ⇒ Links
Returns a new instance of Links.
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/gooddata/models/links.rb', line 13
def initialize(items)
@data = {}
items.values[0]['links'].each do |item|
category = item['category']
if @data[category]
if @data[category]['category'] == category
@data[category] = { @data[category]['identifier'] => @data[category] }
end
@data[category][item['identifier']] = item
else
@data[category] = item
end
end
end
|
Instance Attribute Details
Returns the value of attribute data.
11
12
13
|
# File 'lib/gooddata/models/links.rb', line 11
def data
@data
end
|
Instance Method Details
#[](category) ⇒ Object
33
34
35
36
|
# File 'lib/gooddata/models/links.rb', line 33
def [](category)
return @data[category]['link'] if @data[category] && @data[category]['link']
@data[category]
end
|
#ambiguous?(category) ⇒ Boolean
42
43
44
|
# File 'lib/gooddata/models/links.rb', line 42
def ambiguous?(category)
!unique?(category)
end
|
#get(category, identifier) ⇒ Object
46
47
48
|
# File 'lib/gooddata/models/links.rb', line 46
def get(category, identifier)
self[category][identifier]
end
|
#links(category, identifier = nil) ⇒ Object
28
29
30
31
|
# File 'lib/gooddata/models/links.rb', line 28
def links(category, identifier = nil)
return Links.new(client.get(self[category])) unless identifier
Links.new client.get(get(category, identifier))
end
|
#unique?(category) ⇒ Boolean
38
39
40
|
# File 'lib/gooddata/models/links.rb', line 38
def unique?(category)
@data[category]['link'].is_a? String
end
|