Sha256: d6cc8d0323558c21fdacbd82df76672b1018875e4d555a93d517589203a5b9ec
Contents?: true
Size: 800 Bytes
Versions: 21
Compression:
Stored size: 800 Bytes
Contents
module Locomotive class EditableControl < EditableElement ## fields ## field :content, localize: true field :default_content, type: Boolean, default: true 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 content=(value) return if value == self.content self.default_content = false unless self.new_record? super end def content_from_default=(content) if self.default_content? self.content = content.to_s end end end end
Version data entries
21 entries across 21 versions & 1 rubygems