Module: Mongoid::EmbeddedHelper

Defined in:
lib/mongoid/embedded_helper.rb

Defined Under Namespace

Modules: ArrayExt

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(model) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/mongoid/embedded_helper.rb', line 5

def self.included(model)
  model.class_eval do
    alias_method :old_parentize, :parentize
    def parentize(document)
      old_parentize document
      send(:after_parentize) if respond_to?(:after_parentize)
      # run_callbacks(:after_parentize)
    end
  end
end

Instance Method Details

#in_collection(stack = []) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mongoid/embedded_helper.rb', line 16

def in_collection stack = []
  stack.extend(ArrayExt) if stack.empty?
  if embedded?
    stack.add_collection_name self
    if _parent.respond_to?(:in_collection)
      _parent.in_collection(stack)
    else
      iterate_collection_stack stack, _parent
    end
  else
    return self.class if stack.empty?
    iterate_collection_stack stack
  end
end