Class: GatewaySupport

Inherits:
Object
  • Object
show all
Includes:
MerbMerchant::Billing
Defined in:
lib/support/gateway_support.rb

Overview

:nodoc:

Constant Summary collapse

ACTIONS =
[:purchase, :authorize, :capture, :void, :credit, :recurring]

Constants included from MerbMerchant::Billing

MerbMerchant::Billing::AuthorizedNetGateway, MerbMerchant::Billing::BrainTreeGateway

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGatewaySupport

Returns a new instance of GatewaySupport.



12
13
14
15
# File 'lib/support/gateway_support.rb', line 12

def initialize
  @gateways = Gateway.implementations.sort_by(&:name)
  @gateways.delete(MerbMerchant::Billing::BogusGateway)
end

Instance Attribute Details

#gatewaysObject (readonly)

Returns the value of attribute gateways.



10
11
12
# File 'lib/support/gateway_support.rb', line 10

def gateways
  @gateways
end

Instance Method Details

#each_gatewayObject



17
18
19
# File 'lib/support/gateway_support.rb', line 17

def each_gateway
  @gateways.each{|g| yield g }
end

#featuresObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/support/gateway_support.rb', line 21

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_rdocObject



37
38
39
40
41
# File 'lib/support/gateway_support.rb', line 37

def to_rdoc
  each_gateway do |g|
    puts "* {#{g.display_name}}[#{g.homepage_url}] - #{g.supported_countries.join(', ')}"
  end
end

#to_sObject



49
50
51
52
53
# File 'lib/support/gateway_support.rb', line 49

def to_s
  each_gateway do |g|
    puts "#{g.display_name} - #{g.homepage_url} [#{g.supported_countries.join(', ')}]"
  end
end

#to_textileObject



43
44
45
46
47
# File 'lib/support/gateway_support.rb', line 43

def to_textile
  each_gateway do |g|
    puts %/ * "#{g.display_name}":#{g.homepage_url} [#{g.supported_countries.join(', ')}]/
  end
end