Class: Locomotive::EditableControl

Inherits:
EditableElement show all
Defined in:
app/models/locomotive/editable_control.rb

Instance Attribute Summary

Attributes inherited from EditableElement

#block_name, #block_priority, #label

Instance Method Summary collapse

Methods inherited from EditableElement

#_type, #add_current_locale, #block_label, #by_priority, #disabled?, #page, #page_id, #path, #slug

Instance Method Details

#contentObject

fields ##


5
# File 'app/models/locomotive/editable_control.rb', line 5

field :content, localize: true

#content=(value) ⇒ Object


23
24
25
26
27
# File 'app/models/locomotive/editable_control.rb', line 23

def content=(value)
  return if value == self.content
  self.default_content = false unless self.new_record?
  super
end

#content_from_default=(content) ⇒ Object


29
30
31
32
33
# File 'app/models/locomotive/editable_control.rb', line 29

def content_from_default=(content)
  if self.default_content?
    self.content = content.to_s
  end
end

#options=(value) ⇒ Object

methods ##


11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/locomotive/editable_control.rb', line 11

def options=(value)
  if value.respond_to?(:split)
    value = value.split(/\s*\,\s*/).map do |option|
      first, last = *option.split(/\s*=\s*/)
      last ||= first
      { 'value' => first, 'text' => last }
    end
  end

  super(value)
end