Class: Cart::FindOrCreateForParty
- Inherits:
-
Object
- Object
- Cart::FindOrCreateForParty
- Defined in:
- app/services/cart/find_or_create_for_party.rb
Constant Summary collapse
- 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.
17 18 19 |
# File 'app/services/cart/find_or_create_for_party.rb', line 17 def initialize(party) @party = party end |
Class Method Details
.call(party) ⇒ Object
13 14 15 |
# File 'app/services/cart/find_or_create_for_party.rb', line 13 def self.call(party) new(party).call end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 27 |
# File 'app/services/cart/find_or_create_for_party.rb', line 21 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 |