Class: MongoDoc::Associations::ProxyBase

Inherits:
Object
  • Object
show all
Defined in:
lib/mongodoc/associations/proxy_base.rb

Direct Known Subclasses

CollectionProxy, DocumentProxy, HashProxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ProxyBase

Returns a new instance of ProxyBase.



20
21
22
23
24
25
# File 'lib/mongodoc/associations/proxy_base.rb', line 20

def initialize(options)
  @assoc_name = options[:assoc_name]
  @assoc_class = options[:assoc_class]
  @_root = options[:root]
  @_parent = options[:parent]
end

Instance Attribute Details

#_parentObject

Returns the value of attribute _parent.



6
7
8
# File 'lib/mongodoc/associations/proxy_base.rb', line 6

def _parent
  @_parent
end

#_rootObject

Returns the value of attribute _root.



6
7
8
# File 'lib/mongodoc/associations/proxy_base.rb', line 6

def _root
  @_root
end

#assoc_classObject (readonly)

Returns the value of attribute assoc_class.



6
7
8
# File 'lib/mongodoc/associations/proxy_base.rb', line 6

def assoc_class
  @assoc_class
end

#assoc_nameObject (readonly)

Returns the value of attribute assoc_name.



6
7
8
# File 'lib/mongodoc/associations/proxy_base.rb', line 6

def assoc_name
  @assoc_name
end

Instance Method Details

#_path_to_root(src, attrs) ⇒ Object



12
13
14
# File 'lib/mongodoc/associations/proxy_base.rb', line 12

def _path_to_root(src, attrs)
  _parent._path_to_root(src, annotated_keys(src, attrs))
end

#attach(item) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/mongodoc/associations/proxy_base.rb', line 27

def attach(item)
  if is_document?(item)
    item._parent = self
    item._root = _root
    _root.send(:register_save_observer, item)
  end
  item
end