Sha256: 72ba038c88f7606e6953e87e9a7389de56cf056e3464499b5b04c4471253b7fc

Contents?: true

Size: 734 Bytes

Versions: 3

Compression:

Stored size: 734 Bytes

Contents

# frozen_string_literal: true

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, nil)
      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 model
        data.try(:model)
      end

      def show_file?
        file.present? && (file.filename || file.path)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
administrate-field-carrierwave-0.6.0 lib/administrate/field/carrierwave.rb
administrate-field-carrierwave-0.5.0 lib/administrate/field/carrierwave.rb
administrate-field-carrierwave-0.4.1 lib/administrate/field/carrierwave.rb