Module: Mongoid::Hierarchy::ClassMethods
- Defined in:
- lib/mongoid/hierarchy.rb
Instance Method Summary collapse
-
#hereditary? ⇒ true, false
Determines if the document is a subclass of another document.
-
#inherited(subclass) ⇒ Object
When inheriting, we want to copy the fields from the parent class and set the on the child to start, mimicking the behaviour of the old class_inheritable_accessor that was deprecated in Rails edge.
Instance Method Details
#hereditary? ⇒ true, false
Determines if the document is a subclass of another document.
128 129 130 |
# File 'lib/mongoid/hierarchy.rb', line 128 def hereditary? Mongoid::Document > superclass end |
#inherited(subclass) ⇒ Object
When inheriting, we want to copy the fields from the parent class and set the on the child to start, mimicking the behaviour of the old class_inheritable_accessor that was deprecated in Rails edge.
142 143 144 145 146 147 148 |
# File 'lib/mongoid/hierarchy.rb', line 142 def inherited(subclass) super subclass.fields = fields.dup subclass.pre_processed_defaults = pre_processed_defaults.dup subclass.post_processed_defaults = post_processed_defaults.dup subclass.scopes = scopes.dup end |