module Shrine::Plugins::Column::AttacherMethods

  1. lib/shrine/plugins/column.rb

Methods

Public Class

  1. new

Public Instance

  1. column_data
  2. column_serializer
  3. load_column

Attributes

column_serializer [R]

Column serializer object.

Public Class methods

new(column_serializer: shrine_class.opts[:column][:serializer], **options)

Allows overriding the default column serializer.

[show source]
   # File lib/shrine/plugins/column.rb
31 def initialize(column_serializer: shrine_class.opts[:column][:serializer], **options)
32   super(**options)
33   @column_serializer = column_serializer
34 end

Public Instance methods

column_data()

Returns attacher data as a serialized string (JSON by default).

attacher.column_data #=> '{"id":"...","storage":"...","metadata":{...}}'
[show source]
   # File lib/shrine/plugins/column.rb
48 def column_data
49   serialize_column(data)
50 end
load_column(data)

Loads attachment from column data.

attacher.file #=> nil
attacher.load_column('{"id":"...","storage":"...","metadata":{...}}')
attacher.file #=> #<Shrine::UploadedFile>
[show source]
   # File lib/shrine/plugins/column.rb
41 def load_column(data)
42   load_data(deserialize_column(data))
43 end