Sha256: d1230ff9d9c385029d5919ba23178c981d987b1c65ecc187c934a8153f3f6b49

Contents?: true

Size: 834 Bytes

Versions: 27

Compression:

Stored size: 834 Bytes

Contents

module Locomotive
  module API
    module Forms

      class EditableElementForm < BaseForm

        TYPES = %w(file text control)

        # Fix bug in Rails: http://stackoverflow.com/questions/18472876/instantiate-mongoid-subclasses-by-type-field
        TYPES.each do |type|
          "Locomotive::Editable#{type.classify}".constantize.inspect
        end

        attrs :_id, :_type, :block, :slug, :priority, :hint, :content

        def content=(value)
          if value.respond_to?(:original_filename) || value.respond_to?(:tempfile)
            self._type = :file
          end

          set_attribute :content, value
        end

        def _type=(type)
          return unless TYPES.include?(type.to_s)
          set_attribute :_type, "Locomotive::Editable#{type.to_s.classify}"
        end

      end

    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
locomotivecms-3.3.0 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.3.0.rc3 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.3.0.rc2 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.1.2 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.2.1 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.3.0.rc1 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.2.0 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.2.0.rc2 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.2.0.rc1 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.1.1 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.1.0 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.1.0.rc3 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.1.0.rc2 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.1.0.rc1 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.0.1 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.0.0 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.0.0.rc7 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.0.0.rc6 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.0.0.rc5 app/api/locomotive/api/forms/editable_element_form.rb
locomotivecms-3.0.0.rc4 app/api/locomotive/api/forms/editable_element_form.rb