module Concurrent::Concern::Dereferenceable
def apply_deref_options(value)
def apply_deref_options(value) return nil if value.nil? return value if @do_nothing_on_deref 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 ns_set_deref_options(opts)
@!macro dereferenceable_set_deref_options
def ns_set_deref_options(opts) @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) nil end
def set_deref_options(opts = {})
(**opts)
-
:copy_on_deref
(String
) -- call the given `Proc` passing -
: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 = {}) synchronize{ ns_set_deref_options(opts) } end
def value
-
(Object)
- the current value of the object
def value synchronize { apply_deref_options(@value) } end
def value=(value)
-
value
(Object
) -- the new value
def value=(value) synchronize{ @value = value } end