Class: GoodData::StyleSetting
- Inherits:
-
Rest::Resource
- Object
- Rest::Object
- Rest::Resource
- GoodData::StyleSetting
- Defined in:
- lib/gooddata/models/style_setting.rb
Constant Summary collapse
- STYLE_SETTING_PATH =
'/gdc/projects/%s/styleSettings'
- EMPTY_OBJECT =
{ 'styleSettings' => { 'chartPalette' => [] } }
Instance Attribute Summary collapse
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
Attributes inherited from Rest::Object
Class Method Summary collapse
- .create(colors, opts = { client: GoodData.connection, project: GoodData.project }) ⇒ Object
- .current(opts = { client: GoodData.connection, project: GoodData.project }) ⇒ Object
- .reset(opts = { client: GoodData.connection, project: GoodData.project }) ⇒ Object
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(json) ⇒ StyleSetting
constructor
A new instance of StyleSetting.
Methods included from Mixin::ObjId
Methods inherited from Rest::Object
client, default_client, #saved?
Methods included from Mixin::DataPropertyReader
Methods included from Mixin::DataPropertyWriter
Methods included from Mixin::MetaPropertyReader
Methods included from Mixin::MetaPropertyWriter
Methods included from Mixin::MetaGetter
Methods included from Mixin::DataGetter
Methods included from Mixin::RootKeyGetter
Methods included from Mixin::ContentGetter
Constructor Details
#initialize(json) ⇒ StyleSetting
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
#colors ⇒ Object (readonly)
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 |