module Concurrent::Dereferenceable

def apply_deref_options(value) # :nodoc:

:nodoc:
@!visibility private
def apply_deref_options(value) # :nodoc:
  return nil if value.nil?
  return value if @do_nothing_on_deref
  value = value
  value = @copy_on_deref.call(value) if @copy_on_deref
  value = value.dup if @dup_on_deref
  value = value.freeze if @freeze_on_deref
  value
end

def init_mutex

Other tags:
    See: #mutex -

Other tags:
    Note: - This method *must* be called from within the constructor of the including class.
def init_mutex
  @mutex = Mutex.new
end

def mutex

Returns:
  • (Mutex) - the synchronization object
def mutex
  @mutex
end

def set_deref_options(opts = {})

Options Hash: (**opts)
  • :copy_on_deref (String) -- call the given +Proc+ passing the internal value and
  • :freeze_on_deref (String) -- call +#freeze+ before returning the data
  • :dup_on_deref (String) -- call +#dup+ before returning the data

Parameters:
  • opts (Hash) -- the options defining dereference behavior.

Other tags:
    Note: - Most classes that include this module will call +#set_deref_options+
def set_deref_options(opts = {})
  mutex.synchronize do
    @dup_on_deref = opts[:dup_on_deref] || opts[:dup]
    @freeze_on_deref = opts[:freeze_on_deref] || opts[:freeze]
    @copy_on_deref = opts[:copy_on_deref] || opts[:copy]
    @do_nothing_on_deref = ! (@dup_on_deref || @freeze_on_deref || @copy_on_deref)
  end
end

def value

Returns:
  • (Object) - the current value of the object
def value
  mutex.synchronize do
    apply_deref_options(@value)
  end
end