Class: Jackpot::Card
- Inherits:
-
Object
- Object
- Jackpot::Card
- Defined in:
- app/models/jackpot/card.rb
Overview
A simple decorator to Active Merchant’s Card.
Instance Method Summary collapse
-
#initialize(card_hash) ⇒ Card
constructor
A new instance of Card.
- #masquerade_number ⇒ Object
- #method_missing(meth, *args) ⇒ Object
- #respond_to?(meth) ⇒ Boolean
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_number ⇒ Object
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
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 |