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

#initialize(card_hash) ⇒ Card

Returns 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

#method_missing(meth, *args) ⇒ Object



10
11
12
13
14
15
16
# File 'app/models/jackpot/card.rb', line 10

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

Instance Method Details

#masquerade_numberObject



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

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

#respond_to?(meth) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'app/models/jackpot/card.rb', line 18

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