forked from Shopify/active_fulfillment
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converted to new autoload style for active_merchant common classes
- Loading branch information
Showing
12 changed files
with
63 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.
File renamed without changes.