Class: Maglev::SectionGenerator::SectionSetting
- Inherits:
-
Object
- Object
- Maglev::SectionGenerator::SectionSetting
- Defined in:
- lib/generators/maglev/section_generator.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#default ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity.
-
#initialize(id, type, label = nil) ⇒ SectionSetting
constructor
A new instance of SectionSetting.
-
#value? ⇒ Boolean
rubocop:enable Metrics/CyclomaticComplexity.
Constructor Details
#initialize(id, type, label = nil) ⇒ SectionSetting
Returns a new instance of SectionSetting.
95 96 97 98 99 |
# File 'lib/generators/maglev/section_generator.rb', line 95 def initialize(id, type, label = nil) @id = id @type = type || 'text' @label = label || id.humanize end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
93 94 95 |
# File 'lib/generators/maglev/section_generator.rb', line 93 def id @id end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
93 94 95 |
# File 'lib/generators/maglev/section_generator.rb', line 93 def label @label end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
93 94 95 |
# File 'lib/generators/maglev/section_generator.rb', line 93 def type @type end |
Instance Method Details
#default ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/generators/maglev/section_generator.rb', line 102 def default case type when 'text' then label when 'image' then '"/theme/image-placeholder.jpg"' when 'checkbox' then true when 'link' then '"#"' when 'color' then '#E5E7EB' when 'radio', 'select' then 'option_1' when 'icon' then 'default-icon-class' end end |
#value? ⇒ Boolean
rubocop:enable Metrics/CyclomaticComplexity
115 116 117 |
# File 'lib/generators/maglev/section_generator.rb', line 115 def value? !%w[hint content_type].include?(type) end |