Class: Locomotive::Wagon::Generators::SectionSetting
- Inherits:
-
Object
- Object
- Locomotive::Wagon::Generators::SectionSetting
- Defined in:
- lib/locomotive/wagon/generators/section.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
- #has_value? ⇒ Boolean
-
#initialize(id, type, label = nil) ⇒ SectionSetting
constructor
A new instance of SectionSetting.
Constructor Details
#initialize(id, type, label = nil) ⇒ SectionSetting
Returns a new instance of SectionSetting.
151 152 153 |
# File 'lib/locomotive/wagon/generators/section.rb', line 151 def initialize(id, type, label = nil) @id, @type, @label = id, type || 'text', label || id.humanize end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
149 150 151 |
# File 'lib/locomotive/wagon/generators/section.rb', line 149 def id @id end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
149 150 151 |
# File 'lib/locomotive/wagon/generators/section.rb', line 149 def label @label end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
149 150 151 |
# File 'lib/locomotive/wagon/generators/section.rb', line 149 def type @type end |
Instance Method Details
#default ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/locomotive/wagon/generators/section.rb', line 155 def default case type when 'text' then "\"#{Faker::Lorem.sentence}\"" when 'image_picker' then "\"/samples/images/default.svg\"" when 'asset_picker' then "\"/samples/images/default.svg\"" when 'checkbox' then true when 'radio', 'select' then 'option_1' when 'url' then "\"#\"" else nil end end |
#has_value? ⇒ Boolean
168 169 170 |
# File 'lib/locomotive/wagon/generators/section.rb', line 168 def has_value? !%w(hint content_type).include?(type) end |