lib/mongoid/locker.rb in mongoid-locker-2.0.0 vs lib/mongoid/locker.rb in mongoid-locker-2.0.1

- old
+ new

@@ -1,7 +1,8 @@ # frozen_string_literal: true +require 'forwardable' require 'securerandom' module Mongoid module Locker class << self @@ -101,10 +102,12 @@ self.locking_name_generator = :secure_locking_name end # @api private def included(klass) + klass.extend(Forwardable) unless klass.ancestors.include?(Forwardable) + klass.extend ClassMethods klass.singleton_class.instance_eval { attr_accessor(*MODULE_METHODS) } klass.locking_name_field = locking_name_field klass.locked_at_field = locked_at_field @@ -112,10 +115,10 @@ klass.locker_write_concern = locker_write_concern klass.maximum_backoff = maximum_backoff klass.backoff_algorithm = backoff_algorithm klass.locking_name_generator = locking_name_generator - klass.delegate(*MODULE_METHODS, to: :class) + klass.def_delegators(klass, *MODULE_METHODS) klass.singleton_class.delegate(*(methods(false) - MODULE_METHODS.flat_map { |method| [method, "#{method}=".to_sym] } - %i[included reset! configure]), to: self) end end reset!