Class: OpenPayResourceFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/openpay/open_pay_resource_factory.rb

Class Method Summary collapse

Class Method Details

.create(resource, merchant_id, private_key, production, timeout, country) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/openpay/open_pay_resource_factory.rb', line 2

def OpenPayResourceFactory::create(resource, merchant_id, private_key, production, timeout, country)
  begin
    resource = resource.capitalize
    if country == "co"
      resource = "#{resource}Co".to_sym
    end
    if country == "pe"
      resource = "#{resource}Pe".to_sym
    end
    Object.const_get(resource).new(merchant_id, private_key, production, timeout, country)
  rescue NameError
    raise OpenpayException.new("Invalid resource name:#{resource}", false)
  end
end