Sha256: bd66cd37d77dcd7882a1046602efbe253ae6a5f05d5a641fbac962abe2432dca

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 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_ids
        ids
      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 ids
        @ids ||= options.fetch(:ids, nil)
      end

      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.2.0 lib/administrate/field/collection_select.rb