Method: Mongoid::Threaded#set

Defined in:
lib/mongoid/threaded.rb

#set(key, value) ⇒ Object

Sets a variable in local storage with the given name to the given value. See #get for a discussion of why this method is necessary, and why Thread#[]= should be avoided in cascading callbacks on embedded children.

Parameters:

  • key (String | Symbol)

    the name of the variable to set.

  • value (Object | nil)

    the value of the variable to set (or nil if you wish to unset the variable)



95
96
97
# File 'lib/mongoid/threaded.rb', line 95

def set(key, value)
  storage[key] = value
end