Class: GatewaySupport
- Inherits:
-
Object
- Object
- GatewaySupport
- Includes:
- ActiveMerchant::Billing
- Defined in:
- lib/support/gateway_support.rb
Overview
:nodoc:
Constant Summary collapse
- ACTIONS =
[:purchase, :authorize, :capture, :void, :credit, :recurring]
Instance Attribute Summary collapse
-
#gateways ⇒ Object
readonly
Returns the value of attribute gateways.
Instance Method Summary collapse
- #each_gateway ⇒ Object
- #features ⇒ Object
-
#initialize ⇒ GatewaySupport
constructor
A new instance of GatewaySupport.
- #to_markdown ⇒ Object
- #to_rdoc ⇒ Object
- #to_s ⇒ Object
- #to_textile ⇒ Object
Constructor Details
#initialize ⇒ GatewaySupport
Returns a new instance of GatewaySupport.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/support/gateway_support.rb', line 13 def initialize Dir[File.(File.dirname(__FILE__) + '/../active_merchant/billing/gateways/*.rb')].each do |f| filename = File.basename(f, '.rb') gateway_name = filename + '_gateway' begin gateway_class = ('ActiveMerchant::Billing::' + gateway_name.camelize).constantize rescue NameError puts "Could not load gateway " + gateway_name.camelize + " from " + f + "." end end @gateways = Gateway.implementations.sort_by(&:name) @gateways.delete(ActiveMerchant::Billing::BogusGateway) end |
Instance Attribute Details
#gateways ⇒ Object (readonly)
Returns the value of attribute gateways.
11 12 13 |
# File 'lib/support/gateway_support.rb', line 11 def gateways @gateways end |
Instance Method Details
#each_gateway ⇒ Object
27 28 29 |
# File 'lib/support/gateway_support.rb', line 27 def each_gateway @gateways.each{|g| yield g } end |
#features ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/support/gateway_support.rb', line 31 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 |
#to_markdown ⇒ Object
59 60 61 62 63 |
# File 'lib/support/gateway_support.rb', line 59 def to_markdown each_gateway do |g| puts %/* [#{g.display_name}](#{g.homepage_url}) - #{g.supported_countries.join(', ')}/ end end |
#to_rdoc ⇒ Object
47 48 49 50 51 |
# File 'lib/support/gateway_support.rb', line 47 def to_rdoc each_gateway do |g| puts "* {#{g.display_name}}[#{g.homepage_url}] - #{g.supported_countries.join(', ')}" end end |
#to_s ⇒ Object
65 66 67 68 69 |
# File 'lib/support/gateway_support.rb', line 65 def to_s each_gateway do |g| puts "#{g.display_name} - #{g.homepage_url} [#{g.supported_countries.join(', ')}]" end end |
#to_textile ⇒ Object
53 54 55 56 57 |
# File 'lib/support/gateway_support.rb', line 53 def to_textile each_gateway do |g| puts %/ * "#{g.display_name}":#{g.homepage_url} [#{g.supported_countries.join(', ')}]/ end end |