Module: Shrine::Plugins::Versions::ClassMethods
- Defined in:
- lib/shrine/plugins/versions.rb
Instance Method Summary collapse
-
#uploaded_file(object) ⇒ Object
Converts a hash of data into a hash of versions.
- #version_fallbacks ⇒ Object
Instance Method Details
#uploaded_file(object) ⇒ Object
Converts a hash of data into a hash of versions.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# 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 ⇒ Object
20 21 22 |
# File 'lib/shrine/plugins/versions.rb', line 20 def version_fallbacks opts[:versions][:fallbacks] end |