Module: Decidim::HasSettings
Instance Method Summary collapse
- #current_settings ⇒ Object
- #default_step_settings ⇒ Object
- #default_step_settings=(data) ⇒ Object
- #settings ⇒ Object
- #settings=(data) ⇒ Object
- #step_settings ⇒ Object
- #step_settings=(data) ⇒ Object
Instance Method Details
#current_settings ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/decidim/has_settings.rb', line 29 def current_settings if participatory_space.allows_steps? active_step_settings else default_step_settings end end |
#default_step_settings ⇒ Object
37 38 39 |
# File 'lib/decidim/has_settings.rb', line 37 def default_step_settings new_settings_schema(:step, self[:settings]["default_step"]) end |
#default_step_settings=(data) ⇒ Object
41 42 43 |
# File 'lib/decidim/has_settings.rb', line 41 def default_step_settings=(data) self[:settings]["default_step"] = new_settings_schema(:step, data) end |
#settings ⇒ Object
21 22 23 |
# File 'lib/decidim/has_settings.rb', line 21 def settings new_settings_schema(:global, self[:settings]["global"]) end |
#settings=(data) ⇒ Object
25 26 27 |
# File 'lib/decidim/has_settings.rb', line 25 def settings=(data) self[:settings]["global"] = new_settings_schema(:global, data) end |
#step_settings ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/decidim/has_settings.rb', line 45 def step_settings return {} unless participatory_space.allows_steps? participatory_space.steps.each_with_object({}) do |step, result| result[step.id.to_s] = new_settings_schema(:step, self[:settings].dig("steps", step.id.to_s)) end end |
#step_settings=(data) ⇒ Object
53 54 55 56 57 |
# File 'lib/decidim/has_settings.rb', line 53 def step_settings=(data) self[:settings]["steps"] = data.each_with_object({}) do |(key, value), result| result[key.to_s] = new_settings_schema(:step, value) end end |