Class: Opensteam::Payment::Base
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Opensteam::Payment::Base
- Includes:
- StateMachine
- Defined in:
- lib/opensteam/payment.rb
Overview
Base Class for all Payment Implementations
Direct Known Subclasses
Constant Summary collapse
- @@payment_types =
[]
Class Method Summary collapse
-
.[](payment_id) ⇒ Object
retrieve a payment-implementation class using the :payment_id Ex: class CreditCardPayment < Opensteam::Payment::Base self.payment_id = :credit_card end.
-
.inherited(sub) ⇒ Object
:nodoc:.
- .new_with_type(*attr, &block) ⇒ Object
Methods included from StateMachine
Class Method Details
.[](payment_id) ⇒ Object
179 180 181 |
# File 'lib/opensteam/payment.rb', line 179 def [](payment_id) @@payment_types.find { |t| t.payment_id.to_sym == payment_id.to_sym } end |
.inherited(sub) ⇒ Object
:nodoc:
167 168 169 |
# File 'lib/opensteam/payment.rb', line 167 def inherited(sub) #:nodoc: @@payment_types << sub end |
.new_with_type(*attr, &block) ⇒ Object
185 186 187 188 189 190 191 |
# File 'lib/opensteam/payment.rb', line 185 def new_with_type( *attr, &block ) if( h = attr.first).is_a? Hash and (type = h["type"] || h[:type] ) and ( klass = type.constantize ) != self raise "#{klass} is not a subclass of #{self}" unless klass < self return klass.new( *attr, &block ) end new_without_type( *attr, &block ) end |