Sha256: 15598a5a25ffc2422d0dcac7a9fc78c5b2f20a5b3ae93aeecf67ccc93f93ffb6

Contents?: true

Size: 715 Bytes

Versions: 3

Compression:

Stored size: 715 Bytes

Contents

module Para
  module Component
    class SingletonResource < Para::Component::Resource
      register :singleton_resource, self

      configurable_on :model_type, as: :selectize, collection: :available_models

      has_one :component_resource, class_name: 'Para::ComponentResource',
              foreign_key: :component_id, autosave: true, dependent: :destroy

      def resource
        build_component_resource(resource: model.new) unless component_resource
        component_resource.resource ||= model.new
      end

      def resource=(value)
        build_component_resource(resource: value) unless component_resource
      end

      def default_form_actions
        [:submit]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
para-0.5.3 app/models/para/component/singleton_resource.rb
para-0.5.1 app/models/para/component/singleton_resource.rb
para-0.5.0 app/models/para/component/singleton_resource.rb