module Shrine::Plugins::Versions::ClassMethods

  1. lib/shrine/plugins/versions.rb

Methods

Public Instance

  1. uploaded_file
  2. version_fallbacks

Public Instance methods

uploaded_file(object)

Converts a hash of data into a hash of versions.

[show source]
   # File lib/shrine/plugins/versions.rb
25 def uploaded_file(object)
26   object = JSON.parse(object) if object.is_a?(String)
27 
28   Utils.deep_map(object, transform_keys: :to_sym) do |path, value|
29     if value.is_a?(Hash) && (value["id"].is_a?(String) || value[:id].is_a?(String))
30       file = super(value)
31     elsif value.is_a?(UploadedFile)
32       file = value
33     end
34 
35     if file
36       yield file if block_given?
37       file
38     end
39   end
40 end
version_fallbacks()
[show source]
   # File lib/shrine/plugins/versions.rb
20 def version_fallbacks
21   opts[:versions][:fallbacks]
22 end