Module: MongoDoc::Associations::ProxyBase

Included in:
CollectionProxy, DocumentProxy, HashProxy
Defined in:
lib/mongodoc/associations/proxy_base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



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

def self.included(klass)
  klass.class_eval do
    attr_reader :assoc_name, :assoc_class, :_parent, :_root
  end
end

Instance Method Details

#_parent=(parent) ⇒ Object



10
11
12
# File 'lib/mongodoc/associations/proxy_base.rb', line 10

def _parent=(parent)
  @_parent = parent
end

#_path_to_root(src, attrs) ⇒ Object



14
15
16
# File 'lib/mongodoc/associations/proxy_base.rb', line 14

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

#_root=(root) ⇒ Object



18
19
20
# File 'lib/mongodoc/associations/proxy_base.rb', line 18

def _root=(root)
  @_root = root
end

#attach(item) ⇒ Object



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

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

#initialize(options) ⇒ Object



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

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