Sha256: c0b35d51cbc16bf6abc9a46616eb86bb9b55f443df6d5378be0603cc23960246

Contents?: true

Size: 819 Bytes

Versions: 1

Compression:

Stored size: 819 Bytes

Contents

require 'administrate/field/base'
require 'rails'

module Administrate
  module Field
    class Carrierwave < Administrate::Field::Base
      class Engine < ::Rails::Engine; end

      def image
        options.fetch(:image, '')
      end

      def image_on_index?
        options.fetch(:image_on_index, false)
      end

      def multiple?
        options.fetch(:multiple, false)
      end

      def remove?
        options.fetch(:remove, false)
      end

      def remote_url?
        options.fetch(:remote_url, false)
      end

      def files
        Array[*data]
      end

      def file
        files.first
      end

      def show_preview?
        data.model.persisted? && file.version_exists?(image) && data.file.present?
      end

      def show_file?
        file.present?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
administrate-field-carrierwave-0.3.2 lib/administrate/field/carrierwave.rb