Sha256: a29a27d9e46f9eb9d8c58f84343061a0ea0f5866df051248f19461dce3ed5d19

Contents?: true

Size: 786 Bytes

Versions: 5

Compression:

Stored size: 786 Bytes

Contents

module Avo
  module Fields
    class FileField < BaseField
      attr_accessor :is_avatar
      attr_accessor :is_image

      def initialize(name, **args, &block)
        @defaults = {
          partial_name: 'file-field',
        }.merge(@defaults || {})

        super(name, **args, &block)

        @file_field = true
        @is_avatar = args[:is_avatar].present? ? args[:is_avatar] : false
        @is_image = args[:is_image].present? ? args[:is_image] : @is_avatar
        @link_to_resource = args[:link_to_resource].present? ? args[:link_to_resource] : false
      end

      def path
        rails_blob_url value
      end

      def variant(resize_to_limit: [128, 128])
        value.variant(resize_to_limit: resize_to_limit).processed.service_url
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
avo-0.5.0.beta9 lib/avo/fields/file_field.rb
avo-0.5.0.beta8 lib/avo/fields/file_field.rb
avo-0.5.0.beta7 lib/avo/fields/file_field.rb
avo-0.5.0.beta6 lib/avo/fields/file_field.rb
avo-0.5.0.beta5 lib/avo/fields/file_field.rb