Method: ActiveRecord::DatabaseMutex::Implementation#initialize

Defined in:
lib/active_record/database_mutex/implementation.rb

#initialize(opts = {}) ⇒ Implementation

The initialize method initializes an instance of the DatabaseMutex class by setting its name and internal_name attributes.

Parameters:

  • opts (Hash) (defaults to: {})

    options hash containing the name key

Options Hash (opts):

  • name (String)

    name for the mutex, required.

Raises:

  • (ArgumentError)

    if no name option is provided in the options hash.



22
23
24
25
26
27
# File 'lib/active_record/database_mutex/implementation.rb', line 22

def initialize(opts = {})
  @name = opts[:name].to_s.downcase
  @name.size != 0 or raise ArgumentError, "mutex requires a nonempty :name argument"
  @name.freeze
  lock_name # create/check internal_name and lock_name
end