Skip to content

Commit

Permalink
Converted to new autoload style for active_merchant common classes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobi committed Jun 27, 2010
1 parent 87269e1 commit 84d735a
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 31 deletions.
8 changes: 3 additions & 5 deletions lib/active_fulfillment.rb
Expand Up @@ -37,13 +37,11 @@
require_gem 'builder'
end


require 'cgi'
require 'net/https'
require 'active_fulfillment/lib/error'
require 'active_fulfillment/lib/requires_parameters'
require 'active_fulfillment/lib/connection'
require 'active_fulfillment/lib/posts_data'
require 'active_fulfillment/lib/country'
require 'rexml/document'
require 'active_merchant/common'

require 'active_fulfillment/fulfillment/base'
require 'active_fulfillment/fulfillment/response'
Expand Down
4 changes: 0 additions & 4 deletions lib/active_fulfillment/lib/error.rb

This file was deleted.

22 changes: 0 additions & 22 deletions lib/active_fulfillment/lib/post_data.rb

This file was deleted.

13 changes: 13 additions & 0 deletions lib/active_merchant/common.rb
@@ -0,0 +1,13 @@
module ActiveMerchant
autoload :Connection, 'active_merchant/common/connection'
autoload :Country, 'active_merchant/common/country'
autoload :ActiveMerchantError, 'active_merchant/common/error'
autoload :ConnectionError, 'active_merchant/common/error'
autoload :RetriableConnectionError, 'active_merchant/common/error'
autoload :ResponseError, 'active_merchant/common/error'
autoload :PostData, 'active_merchant/common/post_data'
autoload :PostsData, 'active_merchant/common/posts_data'
autoload :RequiresParameters, 'active_merchant/common/requires_parameters'
autoload :Utils, 'active_merchant/common/utils'
autoload :Validateable, 'active_merchant/common/validateable'
end
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions lib/active_merchant/common/error.rb
@@ -0,0 +1,23 @@
module ActiveMerchant #:nodoc:
class ActiveMerchantError < StandardError #:nodoc:
end

class ConnectionError < ActiveMerchantError # :nodoc:
end

class RetriableConnectionError < ConnectionError # :nodoc:
end

class ResponseError < ActiveMerchantError # :nodoc:
attr_reader :response

def initialize(response, message = nil)
@response = response
@message = message
end

def to_s
"Failed with #{response.code} #{response.message if response.respond_to?(:message)}"
end
end
end
24 changes: 24 additions & 0 deletions lib/active_merchant/common/post_data.rb
@@ -0,0 +1,24 @@
require 'cgi'

module ActiveMerchant
class PostData < Hash
class_inheritable_accessor :required_fields, :instance_writer => false
self.required_fields = []

def []=(key, value)
return if value.blank? && !required?(key)
super
end

def to_post_data
collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
end

alias_method :to_s, :to_post_data

private
def required?(key)
required_fields.include?(key)
end
end
end
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 84d735a

Please sign in to comment.