Class: GoodData::StyleSetting
Constant Summary
collapse
- STYLE_SETTING_PATH =
'/gdc/projects/%s/styleSettings'
- EMPTY_OBJECT =
{
'styleSettings' => {
'chartPalette' => []
}
}
Instance Attribute Summary collapse
Attributes inherited from Rest::Object
#client, #json, #project
Class Method Summary
collapse
Instance Method Summary
collapse
#obj_id
client, default_client, #saved?
#data_property_reader
#data_property_writer
#metadata_property_reader
#metadata_property_writer
#meta
#data
#root_key
#content
Constructor Details
Returns a new instance of StyleSetting.
52
53
54
55
56
|
# File 'lib/gooddata/models/style_setting.rb', line 52
def initialize(json)
super
@json = json
@colors = json ? data['chartPalette'] : []
end
|
Instance Attribute Details
Returns the value of attribute colors.
19
20
21
|
# File 'lib/gooddata/models/style_setting.rb', line 19
def colors
@colors
end
|
Class Method Details
.create(colors, opts = { client: GoodData.connection, project: GoodData.project }) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/gooddata/models/style_setting.rb', line 29
def create(colors, opts = { client: GoodData.connection, project: GoodData.project })
client, project = GoodData.get_client_and_project(opts)
if colors.is_a?(StyleSetting)
colors = colors.colors
else
colors = colors.uniq
end
uri = STYLE_SETTING_PATH % project.pid
data_to_send = GoodData::Helpers.deep_dup(EMPTY_OBJECT).tap do |d|
d['styleSettings']['chartPalette'] = colors.map { |color| GoodData::Helpers.stringify_keys(color) }
end
style = client.create(StyleSetting, data_to_send)
client.put(uri, data_to_send)
style
end
|
.current(opts = { client: GoodData.connection, project: GoodData.project }) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/gooddata/models/style_setting.rb', line 22
def current(opts = { client: GoodData.connection, project: GoodData.project })
client, project = GoodData.get_client_and_project(opts)
uri = STYLE_SETTING_PATH % project.pid
data = client.get(uri)
client.create(StyleSetting, data)
end
|
.reset(opts = { client: GoodData.connection, project: GoodData.project }) ⇒ Object
45
46
47
48
49
|
# File 'lib/gooddata/models/style_setting.rb', line 45
def reset(opts = { client: GoodData.connection, project: GoodData.project })
client, project = GoodData.get_client_and_project(opts)
uri = STYLE_SETTING_PATH % project.pid
client.delete(uri)
end
|
Instance Method Details
#empty? ⇒ Boolean
58
59
60
|
# File 'lib/gooddata/models/style_setting.rb', line 58
def empty?
colors.empty?
end
|