Class: Cart::FindOrCreateForParty
- Inherits:
-
Object
- Object
- Cart::FindOrCreateForParty
- Defined in:
- app/services/cart/find_or_create_for_party.rb
Overview
Service object: find or create for party.
Constant Summary collapse
- LOCK_TIMEOUT_SECONDS =
Lock timeout seconds.
10
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(party) ⇒ FindOrCreateForParty
constructor
A new instance of FindOrCreateForParty.
Constructor Details
#initialize(party) ⇒ FindOrCreateForParty
Returns a new instance of FindOrCreateForParty.
19 20 21 |
# File 'app/services/cart/find_or_create_for_party.rb', line 19 def initialize(party) @party = party end |
Class Method Details
.call(party) ⇒ Object
15 16 17 |
# File 'app/services/cart/find_or_create_for_party.rb', line 15 def self.call(party) new(party).call end |
Instance Method Details
#call ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/services/cart/find_or_create_for_party.rb', line 23 def call cart = nil Party.with_advisory_lock(lock_key, timeout_seconds: LOCK_TIMEOUT_SECONDS) do cart = find_or_create_under_lock end cart end |