Class: MockChargebee::Models::Customer
- Inherits:
-
Base
- Object
- Base
- MockChargebee::Models::Customer
show all
- Defined in:
- lib/mock_chargebee/models/customer.rb
Constant Summary
collapse
- RESOURCE_ID_PREFIX =
'cust'
Class Method Summary
collapse
Methods inherited from Base
already_exists!, load_fixtures, repositories, unique_id
Class Method Details
.already_exists?(id) ⇒ Boolean
32
33
34
35
36
|
# File 'lib/mock_chargebee/models/customer.rb', line 32
def self.already_exists?(id)
return false if id.nil?
repositories.customers[id].present?
end
|
.create(params) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/mock_chargebee/models/customer.rb', line 14
def self.create(params)
already_exists!(id) if already_exists?(params['id'])
params['id'] ||= unique_id
customer = customer_fixture.merge(params)
repositories.customers.store(customer['id'], customer)
customer
end
|
.find(id) ⇒ Object
10
11
12
|
# File 'lib/mock_chargebee/models/customer.rb', line 10
def self.find(id)
repositories.customers.fetch(id)
end
|
.update(id, params) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/mock_chargebee/models/customer.rb', line 24
def self.update(id, params)
customer = find(id)
customer.merge!(params)
repositories.customers.store(customer['id'], customer)
customer
end
|