Sha256: 1e4787e897c2dc478ab2a138528229fdf1c14941686544c44dddab1acdc95bd0
Contents?: true
Size: 1.12 KB
Versions: 9
Compression:
Stored size: 1.12 KB
Contents
module Locomotive class EditableControl < EditableElement ## fields ## field :content field :options, :type => Array, :default => [] ## methods ## 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 def default_content? false end def copy_attributes_from(el) super(el) %w(content options).each do |meth| self.attributes[meth] = el.attributes[meth] end end def as_json(options = {}) Locomotive::EditableControlPresenter.new(self).as_json end protected def propagate_content if self.content_changed? operations = { '$set' => { 'editable_elements.$.content' => self.content, 'editable_elements.$.options' => self.options, } } self.page.collection.update self._selector, operations, :multi => true end true end end end
Version data entries
9 entries across 9 versions & 1 rubygems