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.
100 101 102 103 104 |
# File 'lib/generators/maglev/section_generator.rb', line 100 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.
98 99 100 |
# File 'lib/generators/maglev/section_generator.rb', line 98 def id @id end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
98 99 100 |
# File 'lib/generators/maglev/section_generator.rb', line 98 def label @label end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
98 99 100 |
# File 'lib/generators/maglev/section_generator.rb', line 98 def type @type end |
Instance Method Details
#default ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/generators/maglev/section_generator.rb', line 107 def default case type when 'text' then label when 'image' then '"/theme/image-placeholder.jpg"' when 'checkbox' then true when 'link' then '{ text: "Link", href: "#" }' when 'color' then '#E5E7EB' when 'radio', 'select' then 'option_1' when 'icon' then 'default-icon-class' when 'collection_item' then 'any' end end |
#value? ⇒ Boolean
rubocop:enable Metrics/CyclomaticComplexity
121 122 123 |
# File 'lib/generators/maglev/section_generator.rb', line 121 def value? !%w[hint content_type].include?(type) end |