Sha256: ec203b6a81cedd05f65c390880e6278c2cabc1c73591a9086072a3ca1946f50f

Contents?: true

Size: 603 Bytes

Versions: 19

Compression:

Stored size: 603 Bytes

Contents

module Avo
  module Fields
    class FilesField < BaseField
      attr_accessor :is_image

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

        @is_image = args[:is_image].present? ? args[:is_image] : @is_avatar
      end

      def view_component_name
        "FilesField"
      end

      def to_permitted_param
        {"#{id}": []}
      end

      def fill_field(model, key, value)
        return model unless model.methods.include? key.to_sym

        value.each do |file|
          model.send(key).attach file
        end

        model
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
avo-1.6.4.pre.1 lib/avo/fields/files_field.rb
avo-1.6.3.pre.2 lib/avo/fields/files_field.rb
avo-1.6.3.pre.1 lib/avo/fields/files_field.rb
avo-1.6.2.pre.1 lib/avo/fields/files_field.rb
avo-1.6.1 lib/avo/fields/files_field.rb
avo-1.6.0 lib/avo/fields/files_field.rb
avo-1.5.5 lib/avo/fields/files_field.rb
avo-1.5.4 lib/avo/fields/files_field.rb
avo-1.5.3 lib/avo/fields/files_field.rb
avo-1.5.2 lib/avo/fields/files_field.rb
avo-1.5.1 lib/avo/fields/files_field.rb
avo-1.5.0 lib/avo/fields/files_field.rb
avo-1.4.5.pre.1 lib/avo/fields/files_field.rb
avo-1.4.4.pre.1 lib/avo/fields/files_field.rb
avo-1.4.4 lib/avo/fields/files_field.rb
avo-1.4.3 lib/avo/fields/files_field.rb
avo-1.4.2 lib/avo/fields/files_field.rb
avo-1.4.1 lib/avo/fields/files_field.rb
avo-1.4.0 lib/avo/fields/files_field.rb