module Shrine::Plugins::UrlsafeSerialization::FileMethods

  1. lib/shrine/plugins/_urlsafe_serialization.rb

Methods

Public Instance

  1. urlsafe_data
  2. urlsafe_dump

Public Instance methods

urlsafe_data(metadata: [])
[show source]
   # File lib/shrine/plugins/_urlsafe_serialization.rb
30 def urlsafe_data(metadata: [])
31   data = self.data.dup
32 
33   if metadata.any?
34     # order metadata in the specified order
35     data["metadata"] = metadata
36       .map { |name| [name, self.metadata[name]] }
37       .to_h
38   else
39     # save precious characters
40     data.delete("metadata")
41   end
42 
43   data
44 end
urlsafe_dump(**options)
[show source]
   # File lib/shrine/plugins/_urlsafe_serialization.rb
26 def urlsafe_dump(**options)
27   self.class.urlsafe_dump(self, **options)
28 end