Module: UseCases::ModuleOptins::Locked::CallPatch

Defined in:
lib/use_cases/module_optins/locked.rb

Instance Method Summary collapse

Instance Method Details

#callObject

Raises:



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/use_cases/module_optins/locked.rb', line 29

def call(...)
  unless self.class._lock_with
    raise MissingLockConfiguration, "Locked use cases require setting `lock_with` to define the cache key and wait configuration.\n" \
                                    " Example: `lock_with { |params, curent_user| \"my-key-\#{params[:id]}-\#{curent_user.id}\" }`"
  end

  key = lock_with(...)

  raise MissingLockerError, "Locked use cases require setting `locker` dependency to define the cache store.\n" unless respond_to?(:locker)

  locker.lock(key, lock_options) { super }
end