Sha256: 8420b21cc30c61e2ef5a75f5b704bfd50af976ff5e15e54a4d67361e88c7af70

Contents?: true

Size: 793 Bytes

Versions: 18

Compression:

Stored size: 793 Bytes

Contents

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

      def initialize(id, **args, &block)
        super(id, **args, &block)

        @link_to_resource = args[:link_to_resource].present? ? args[:link_to_resource] : false
        @is_avatar = args[:is_avatar].present? ? args[:is_avatar] : false
        @is_image = args[:is_image].present? ? args[:is_image] : @is_avatar
      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

      def to_image
        return variant(resize_to_limit: [320, 320]) if is_image
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
avo-1.7.2 lib/avo/fields/file_field.rb
avo-1.7.1 lib/avo/fields/file_field.rb
avo-1.7.0 lib/avo/fields/file_field.rb
avo-1.6.4.pre.1 lib/avo/fields/file_field.rb
avo-1.6.3.pre.3 lib/avo/fields/file_field.rb
avo-1.6.3.pre.2 lib/avo/fields/file_field.rb
avo-1.6.3.pre.1 lib/avo/fields/file_field.rb
avo-1.6.2.pre.1 lib/avo/fields/file_field.rb
avo-1.6.1 lib/avo/fields/file_field.rb
avo-1.6.0 lib/avo/fields/file_field.rb
avo-1.5.5 lib/avo/fields/file_field.rb
avo-1.5.4 lib/avo/fields/file_field.rb
avo-1.5.3 lib/avo/fields/file_field.rb
avo-1.5.2 lib/avo/fields/file_field.rb
avo-1.5.1 lib/avo/fields/file_field.rb
avo-1.5.0 lib/avo/fields/file_field.rb
avo-1.4.5.pre.1 lib/avo/fields/file_field.rb
avo-1.4.4.pre.1 lib/avo/fields/file_field.rb