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
15
16
17
18
19
20
21
22
23
# File 'lib/mongoid/embedded_helper.rb', line 5

def self.included(model)
			model.class_eval do
 
    alias_method :old_assimilate, :assimilate        
    def assimilate(parent, options)
      old_assimilate parent, options  
      send(:after_assimilate) if respond_to?(:after_assimilate)
      # run_callbacks(:after_assimilate)
    end
    
    alias_method :old_parentize, :parentize
    def parentize(object, association_name)
      old_parentize object, association_name
      send(:after_parentize) if respond_to?(:after_parentize)
      # run_callbacks(:after_parentize)    
    end  
    
  end
end

Instance Method Details

#in_collection(stack = []) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/mongoid/embedded_helper.rb', line 25

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