Class: Jackpot::Card

Inherits:
Object
  • Object
show all
Defined in:
app/models/jackpot/card.rb

Overview

A simple decorator to Active Merchant's Card.

Instance Method Summary (collapse)

Constructor Details

- (Card) initialize(card_hash)

A new instance of Card



6
7
8
# File 'app/models/jackpot/card.rb', line 6

def initialize(card_hash)
  @component  = ActiveMerchant::Billing::CreditCard.new(HashWithIndifferentAccess.new(card_hash))
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(meth, *args)



14
15
16
17
18
19
20
# File 'app/models/jackpot/card.rb', line 14

def method_missing(meth, *args)
  if @component.respond_to?(meth)
    @component.send(meth, *args)
  else
    super
  end
end

Instance Method Details

- (Object) masquerade_number



28
29
30
# File 'app/models/jackpot/card.rb', line 28

def masquerade_number
  "XXXX-XXXX-XXXX-#{number.last(4)}"
end

- (Boolean) respond_to?(meth)

Returns:

  • (Boolean)


22
23
24
25
26
# File 'app/models/jackpot/card.rb', line 22

def respond_to?(meth)
  unless @component.respond_to?(meth)
    super.respond_to? meth
  end
end

- (Object) type



10
11
12
# File 'app/models/jackpot/card.rb', line 10

def type
  @component.brand
end