Sha256: e532995c312c0916f366f04cf7facc77b5b5a03d4deb6eaeabc7003d7041ee70

Contents?: true

Size: 873 Bytes

Versions: 1

Compression:

Stored size: 873 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, '')
      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? &&
          data&.file.present? &&
          file.version_exists?(image)
      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.3 lib/administrate/field/carrierwave.rb