Skip to content
This repository has been archived by the owner on Sep 24, 2022. It is now read-only.

Commit

Permalink
Fix issue with Base64.
Browse files Browse the repository at this point in the history
  • Loading branch information
y8 committed Mar 5, 2012
1 parent cb44a88 commit 73d8e59
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions lib/paperclip-meta/attachment.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
module Paperclip
module Meta
module Attachment
# Use Base64 class if aviliable, to prevent
# ActiveSupport deprecation warnings.
begin
require "base64"
rescue LoadError
Base64 = ActiveSupport::Base64
end

def self.included(base)
base.send :include, InstanceMethods
Expand Down Expand Up @@ -71,29 +78,14 @@ def meta_read(style, item)

# Return encoded metadata as String
def meta_encode(meta)
# Use Base64 class if aviliable, to prevent
# ActiveSupport deprecation warnings.
if Module.const_defined? "Base64"
::Base64.encode64(Marshal.dump(meta))
else
ActiveSupport::Base64.encode64(Marshal.dump(meta))
end
Base64.encode64(Marshal.dump(meta))
end

# Return decoded metadata as Object
def meta_decode(meta)
# Use Base64 class if aviliable, to prevent
# ActiveSupport deprecation warnings.
if Module.const_defined? "Base64"
Marshal.load(::Base64.decode64(meta))
else
Marshal.load(ActiveSupport::Base64.decode64(meta))
end
Marshal.load(Base64.decode64(meta))
end

end

end

end
end

0 comments on commit 73d8e59

Please sign in to comment.