Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
require 'activeresource' class Braintree < ActiveResource::Base self.site = "https://secure.braintreepaymentgateway.com/api/query.php" ActiveResource::Base.logger = Logger.new("#{File.dirname(__FILE__)}/../../log/braintree.log") class << self ## For a collection call, ActiveResource formatting is not ## compliant with Braintree's output. def instantiate_collection(collection, prefix_options = {}) unless collection.kind_of? Array [instantiate_record(collection, prefix_options)] else collection.collect! { |record| instantiate_record(record, prefix_options) } end end alias :resource_find :find def find(*arguments) output = resource_find(*arguments) if output.respond_to? :err case output.err.code.to_i when 100 raise(ActiveResource::UnauthorizedAccess.new(output.err, output.err.msg)) when 112 raise(ActiveResource::MethodNotAllowed.new(output.err, output.err.msg)) else raise(ConnectionError.new(output.err, "Unknown response code: #{outout.err.code}")) end end output end end end
Pasted June 23, 2008 8:31PM EDT
Embed