lib/support/gateway_support.rb in activemerchant-1.2.1 vs lib/support/gateway_support.rb in activemerchant-1.3.0

- old
+ new

@@ -1,26 +1,39 @@ require 'rubygems' require 'active_support' require 'lib/active_merchant' -class GatewaySupport +class GatewaySupport #:nodoc: + ACTIONS = [:purchase, :authorize, :capture, :void, :credit, :recurring] + + include ActiveMerchant::Billing + attr_reader :gateways def initialize - @gateways = [] - ObjectSpace.each_object(Class) do |c| - if c.name =~ /Gateway/ && c.ancestors.reject{|a| a == c}.include?(ActiveMerchant::Billing::Gateway) - gateways << c - end - end - + @gateways = Gateway.implementations.sort_by(&:name) @gateways.delete(ActiveMerchant::Billing::BogusGateway) - @gateways = @gateways.sort_by(&:name) end def each_gateway @gateways.each{|g| yield g } + end + + def features + width = 15 + + print "Name".center(width + 20) + ACTIONS.each{|f| print "#{f.to_s.capitalize.center(width)}" } + puts + + each_gateway do |g| + print "#{g.display_name.ljust(width + 20)}" + ACTIONS.each do |f| + print "#{(g.instance_methods.include?(f.to_s) ? "Y" : "N").center(width)}" + end + puts + end end def to_rdoc each_gateway do |g| puts "* {#{g.display_name}}[#{g.homepage_url}] - #{g.supported_countries.join(', ')}" \ No newline at end of file