Class: Maglev::Theme::StyleSetting
- Inherits:
-
Object
- Object
- Maglev::Theme::StyleSetting
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/maglev/theme/style_setting.rb
Overview
rubocop:disable Style/ClassAndModuleChildren
Instance Attribute Summary collapse
-
#default ⇒ Object
attributes ##.
-
#id ⇒ Object
validations ##.
-
#label ⇒ Object
attributes ##.
-
#options ⇒ Object
attributes ##.
-
#type ⇒ Object
attributes ##.
Class Method Summary collapse
-
.build(hash) ⇒ Object
class methods ##.
- .build_many(list) ⇒ Object
Instance Method Summary collapse
- #build_default_checkbox_content(default) ⇒ Object
-
#build_default_content(custom_default = nil) ⇒ Object
NOTE: any modification to that method must be reflected to the JS editor.
Instance Attribute Details
#default ⇒ Object
attributes ##
9 10 11 |
# File 'app/models/maglev/theme/style_setting.rb', line 9 def default @default end |
#id ⇒ Object
validations ##
9 10 11 |
# File 'app/models/maglev/theme/style_setting.rb', line 9 def id @id end |
#label ⇒ Object
attributes ##
9 10 11 |
# File 'app/models/maglev/theme/style_setting.rb', line 9 def label @label end |
#options ⇒ Object
attributes ##
9 10 11 |
# File 'app/models/maglev/theme/style_setting.rb', line 9 def @options end |
#type ⇒ Object
attributes ##
9 10 11 |
# File 'app/models/maglev/theme/style_setting.rb', line 9 def type @type end |
Class Method Details
.build(hash) ⇒ Object
class methods ##
32 33 34 35 36 37 |
# File 'app/models/maglev/theme/style_setting.rb', line 32 def self.build(hash) attributes = hash.slice('id', 'label', 'type', 'default') = hash.except('id', 'label', 'type', 'default') new(attributes.merge(options: )) end |
.build_many(list) ⇒ Object
39 40 41 |
# File 'app/models/maglev/theme/style_setting.rb', line 39 def self.build_many(list) list.map { |hash| build(hash) } end |
Instance Method Details
#build_default_checkbox_content(default) ⇒ Object
27 28 29 |
# File 'app/models/maglev/theme/style_setting.rb', line 27 def build_default_checkbox_content(default) !default.nil? end |
#build_default_content(custom_default = nil) ⇒ Object
NOTE: any modification to that method must be reflected to the JS editor
18 19 20 21 22 23 24 25 |
# File 'app/models/maglev/theme/style_setting.rb', line 18 def build_default_content(custom_default = nil) default = custom_default || self.default case type.to_sym when :checkbox then build_default_checkbox_content(default) else default || label end end |