mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-05 20:46:14 +01:00
31 lines
614 B
Ruby
31 lines
614 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
require 'pay_zen/item'
|
||
|
require 'stripe/item'
|
||
|
|
||
|
# Payments module
|
||
|
module Payment; end
|
||
|
|
||
|
# Build the corresponding gateway item, according to the provided klass
|
||
|
class Payment::ItemBuilder
|
||
|
attr_reader :instance
|
||
|
|
||
|
def self.build(klass)
|
||
|
builder = new(klass)
|
||
|
builder.instance
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def initialize(klass)
|
||
|
@instance = case klass
|
||
|
when /^PayZen::/
|
||
|
PayZen::Item.new(klass)
|
||
|
when /^Stripe::/
|
||
|
Stripe::Item.new(klass)
|
||
|
else
|
||
|
raise TypeError
|
||
|
end
|
||
|
end
|
||
|
end
|