Module: FatZebra

Extended by:
FatZebra, Forwardable
Included in:
FatZebra
Defined in:
lib/fat_zebra.rb,
lib/fat_zebra/config.rb,
lib/fat_zebra/errors.rb,
lib/fat_zebra/gateway.rb,
lib/fat_zebra/version.rb,
lib/fat_zebra/models/base.rb,
lib/fat_zebra/models/card.rb,
lib/fat_zebra/models/refund.rb,
lib/fat_zebra/models/purchase.rb,
lib/fat_zebra/models/response.rb

Defined Under Namespace

Modules: Models Classes: Config, Gateway, GatewayError, InvalidArgumentError, RequestError

Constant Summary collapse

VERSION =
"2.0.13"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_gatewayObject

Returns the value of attribute _gateway.



29
30
31
# File 'lib/fat_zebra.rb', line 29

def _gateway
  @_gateway
end

#configObject

Returns the value of attribute config.



28
29
30
# File 'lib/fat_zebra.rb', line 28

def config
  @config
end

Instance Method Details

#configure(auth = nil, &block) ⇒ Object

Configure the Fat Zebra gateway

Raises:

  • (ArgumentError)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fat_zebra.rb', line 32

def configure(auth = nil, &block)
  raise ArgumentError, "missing authentication parameters or block" unless auth || block_given?

  if !auth
     self.config = Config.new
     if (block.arity > 0)
       block.call(self.config)
     else
       self.config.instance_eval(&block)
     end
   else
     self.config = Config.from_hash(auth)
   end

   self.config.validate!

   self.configure_gateway

   self.config
end

#configure_gatewayObject



53
54
55
# File 'lib/fat_zebra.rb', line 53

def configure_gateway
  self._gateway = Gateway.configure(self.config)
end

#gatewayObject

Raises:



57
58
59
60
# File 'lib/fat_zebra.rb', line 57

def gateway
  raise GatewayError.new("Please configure the Gateway before use. See FatZebra.configure { }") if self.config.nil?
  self._gateway
end