module Shrine::Plugins::AddMetadata::ClassMethods

Public Instance Methods

add_metadata(name = nil, **options, &block) click to toggle source
# File lib/shrine/plugins/add_metadata.rb, line 12
def add_metadata(name = nil, **options, &block)
  opts[:add_metadata][:definitions] << [name, options, block]

  metadata_method(name) if name
end
metadata_method(*names) click to toggle source
# File lib/shrine/plugins/add_metadata.rb, line 18
def metadata_method(*names)
  names.each { |name| _metadata_method(name) }
end

Private Instance Methods

_metadata_method(name) click to toggle source
# File lib/shrine/plugins/add_metadata.rb, line 24
def _metadata_method(name)
  self::UploadedFile.send(:define_method, name) do
    metadata[name.to_s]
  end
end