Skip to content

Instantly share code, notes, and snippets.

@danielfone
Created June 22, 2015 03:41
Show Gist options
  • Select an option

  • Save danielfone/856bbaafc2e00bfdcab3 to your computer and use it in GitHub Desktop.

Select an option

Save danielfone/856bbaafc2e00bfdcab3 to your computer and use it in GitHub Desktop.
Attachinary monkey patch Rails 4
module Attachinary
module Utils
Rails.logger.warn 'Monkey patched Attachinary::Utilss#process_hash'
def self.process_hash(hash, scope=nil)
file = if hash['id']
Attachinary::File.find hash['id']
else
file = Attachinary::File.new hash.slice('public_id', 'version', 'width', 'height', 'format', 'resource_type')
file.scope = scope.to_s if scope && file.respond_to?(:scope=)
file
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment