Sha256: c248eb28a2b6c46f145ed1d91aad49976bfd43e7250cb7c1e5c85021f6e3b4c5
Contents?: true
Size: 784 Bytes
Versions: 19
Compression:
Stored size: 784 Bytes
Contents
module Locomotive class EditableControl < EditableElement ## fields ## field :content 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
19 entries across 19 versions & 1 rubygems