Module: MongoDoc::Attributes

Defined in:
lib/mongodoc/attributes.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/mongodoc/attributes.rb', line 8

def self.included(klass)
  klass.class_eval do
    class_inheritable_array :_keys
    self._keys = []
    class_inheritable_array :_associations
    self._associations = []

    attr_accessor :_parent
    attr_accessor :_id

    extend ClassMethods
  end
end

Instance Method Details

#_path_to_root(src, attrs) ⇒ Object



34
35
36
37
# File 'lib/mongodoc/attributes.rb', line 34

def _path_to_root(src, attrs)
  return attrs unless _parent
  _parent._path_to_root(self, attrs)
end

#_rootObject



22
23
24
# File 'lib/mongodoc/attributes.rb', line 22

def _root
  @_root
end

#_root=(root) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/mongodoc/attributes.rb', line 26

def _root=(root)
  @_root = root
  _associations.each do|a|
    association = send(a)
    association._root = root if association
  end
end