Module: Biovision::Components::Base::ComponentSettings
- Included in:
- Biovision::Components::BaseComponent
- Defined in:
- app/lib/biovision/components/base/component_settings.rb
Overview
Normalizing component settings
Instance Method Summary collapse
- #default_settings ⇒ Object
- #normalize_settings(data) ⇒ Object
- #reset_settings ⇒ Object
- #settings_flags ⇒ Object
- #settings_numbers ⇒ Object
- #settings_strings ⇒ Object
Instance Method Details
#default_settings ⇒ Object
20 21 22 |
# File 'app/lib/biovision/components/base/component_settings.rb', line 20 def default_settings {} end |
#normalize_settings(data) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'app/lib/biovision/components/base/component_settings.rb', line 29 def normalize_settings(data) result = {} settings_flags.each { |f| result[f] = data[f].to_i == 1 } settings_numbers.each { |n| result[n] = data[n].to_i } settings_strings.each { |s| result[s] = data[s].to_s } result end |
#reset_settings ⇒ Object
24 25 26 |
# File 'app/lib/biovision/components/base/component_settings.rb', line 24 def reset_settings BiovisionComponent[slug]&.update(settings: default_settings) end |
#settings_flags ⇒ Object
8 9 10 |
# File 'app/lib/biovision/components/base/component_settings.rb', line 8 def settings_flags [] end |
#settings_numbers ⇒ Object
12 13 14 |
# File 'app/lib/biovision/components/base/component_settings.rb', line 12 def settings_numbers [] end |
#settings_strings ⇒ Object
16 17 18 |
# File 'app/lib/biovision/components/base/component_settings.rb', line 16 def settings_strings [] end |