Class: Jackpot::Factory

Inherits:
Object
  • Object
show all
Defined in:
lib/jackpot/factory.rb

Instance Method Summary (collapse)

Constructor Details

- (Factory) initialize(gateway_configuration)

A new instance of Factory



7
8
9
# File 'lib/jackpot/factory.rb', line 7

def initialize(gateway_configuration)
  @gateway_configuration = HashWithIndifferentAccess.new gateway_configuration
end

Instance Method Details

- (Object) build



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jackpot/factory.rb', line 11

def build
  if @gateway_configuration[:type] == :braintree
    Jackpot::Gateway.new(ActiveMerchant::Billing::BraintreeGateway.new(
      :login =>    @gateway_configuration['login'], 
      :password => @gateway_configuration['password'], 
      :mode =>     @gateway_configuration['mode'])) 

  elsif @gateway_configuration['type'] == :bogus
     Jackpot::Gateway.new(ActiveMerchant::Billing::BogusGateway.new) 

  else 
    raise Jackpot::Errors::InvalidGateway.new "There is no #{@gateway_configuration['type']}: available options are :braintree, :bogus"
  end 

end