Class: Locomotive::Wagon::Generators::SectionSetting

Inherits:
Object
  • Object
show all
Defined in:
lib/locomotive/wagon/generators/section.rb

Direct Known Subclasses

BlockSetting

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#idObject (readonly)

Returns the value of attribute id.



149
150
151
# File 'lib/locomotive/wagon/generators/section.rb', line 149

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



149
150
151
# File 'lib/locomotive/wagon/generators/section.rb', line 149

def label
  @label
end

#typeObject (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

#defaultObject



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

Returns:

  • (Boolean)


168
169
170
# File 'lib/locomotive/wagon/generators/section.rb', line 168

def has_value?
  !%w(hint content_type).include?(type)
end