module Shrine::Plugins::Versions::ClassMethods

Public Instance Methods

uploaded_file(object) { |file| ... } click to toggle source

Converts a hash of data into a hash of versions.

Calls superclass method
# File lib/shrine/plugins/versions.rb, line 25
def uploaded_file(object)
  object = JSON.parse(object) if object.is_a?(String)

  Utils.deep_map(object, transform_keys: :to_sym) do |path, value|
    if value.is_a?(Hash) && (value["id"].is_a?(String) || value[:id].is_a?(String))
      file = super(value)
    elsif value.is_a?(UploadedFile)
      file = value
    end

    if file
      yield file if block_given?
      file
    end
  end
end
version_fallbacks() click to toggle source
# File lib/shrine/plugins/versions.rb, line 20
def version_fallbacks
  opts[:versions][:fallbacks]
end