Class: Locomotive::EditableControl

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

Instance Method Summary collapse

Methods inherited from EditableElement

#_run_rearrange_callbacks, #add_current_locale, #by_priority, #content_from_default=, #copy_attributes, #disabled?, #disabled_in_all_translations?, #editable?, #page, #set_default_content_from, #slug

Instance Method Details

#contentObject

fields ##



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

field :content

#copy_attributes_from(el) ⇒ Object



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

def copy_attributes_from(el)
  super(el)

  %w(content options).each do |meth|
    self.attributes[meth] = el.attributes[meth]
  end
end

#default_content?Boolean

Returns:



22
23
24
# File 'app/models/locomotive/editable_control.rb', line 22

def default_content?
  false
end

#options=(value) ⇒ Object

methods ##



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

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