Class: Yoda::Store::Objects::Base::Connected

Inherits:
Object
  • Object
show all
Extended by:
ConnectedDelegation
Defined in:
lib/yoda/store/objects/base.rb

Overview

A wrapper class of Yoda::Store::Objects::Base to allow access to registry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConnectedDelegation

delegate_to_object

Constructor Details

#initialize(object, registry:) ⇒ Connected

Returns a new instance of Connected.

Parameters:



34
35
36
37
# File 'lib/yoda/store/objects/base.rb', line 34

def initialize(object, registry:)
  @object = object
  @registry = registry
end

Instance Attribute Details

#objectBase (readonly)

Returns:



24
25
26
# File 'lib/yoda/store/objects/base.rb', line 24

def object
  @object
end

#registryRegistry (readonly)

Returns:



27
28
29
# File 'lib/yoda/store/objects/base.rb', line 27

def registry
  @registry
end

Instance Method Details

#merge(another) ⇒ Object



47
48
49
# File 'lib/yoda/store/objects/base.rb', line 47

def merge(another)
  object.merge(another).with_connection(**connection_options)
end

#meta_classObjects::MetaClassObject::Connected?



52
53
54
# File 'lib/yoda/store/objects/base.rb', line 52

def meta_class
  registry.get(meta_class_address)&.with_connection(**connection_options)
end

#with_connection(**kwargs) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/yoda/store/objects/base.rb', line 39

def with_connection(**kwargs)
  if kwargs == connection_options
    self
  else
    object.with_connection(**kwargs)
  end
end