Class: LocalObject

Inherits:
Object show all
Defined in:
lib/y_support/misc/local_object.rb

Overview

Object, whose business is to stay local to methods. Optional signature provides additional level of safety in ensuring object locality. (Signature accessor is :signature, aliased as :σ, small Greek sigma.)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(signature = caller_locations( 1, 1 )[0].label) ⇒ LocalObject

Optional argument signature provides additional level of safety in ascertaining that the object indeed is of local origin.



16
17
18
# File 'lib/y_support/misc/local_object.rb', line 16

def initialize signature=caller_locations( 1, 1 )[0].label
  @signature = signature
end

Instance Attribute Details

#signatureObject (readonly) Also known as: σ

Returns the value of attribute signature.



10
11
12
# File 'lib/y_support/misc/local_object.rb', line 10

def signature
  @signature
end

Instance Method Details

#local_object?(signature = caller_locations( 1, 1 )[0].label) ⇒ Boolean Also known as: ℓ?

True if the (optional) signature matches.

Returns:

  • (Boolean)


22
23
24
# File 'lib/y_support/misc/local_object.rb', line 22

def local_object? signature=caller_locations( 1, 1 )[0].label
  signature == self.signature
end