Sha256: 26d42331062e9bb56ab3bb66bb817c8352245ee869b0da2bfc1d862d6bae0072

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require 'administrate/field/base'

module Administrate
  module Field
    class CollectionSelect < Base
      class Engine < ::Rails::Engine
      end

      def to_s
        @show_text ||= options.fetch(:show_text, data)
      end

      def selectable_collection
        collection
      end

      def selectable_value
        value_method
      end

      def selectable_text
        text_method
      end

      def selectable_options
        options_method
      end

      def multiple
        multiple_method
      end

      def label
        @label ||= options.fetch(:label, attribute)
      end

      private

      def collection
        @collection ||= options.fetch(:collection, [])
      end

      def value_method
        @value_method ||= options.fetch(:value_method, nil)
      end

      def text_method
        @text_method ||= options.fetch(:text_method, nil)
      end

      def options_method
        @options_method ||= options.fetch(:options, nil)
      end

      def multiple_method
        @multiple_method ||= options.fetch(:multiple, nil)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
administrate-field-collection_select-0.1.0 lib/administrate/field/collection_select.rb