Determines if the document is a subclass of another document.
@example Check if the document is a subclass.
Square.hereditary?
@return [ true, false ] True if hereditary, false if not.
# File lib/mongoid/hierarchy.rb, line 141 def hereditary? Mongoid::Document > superclass end
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.
@example Inherit from this class.
Person.inherited(Doctor)
@param [ Class ] subclass The inheriting class.
@since 2.0.0.rc.6
# File lib/mongoid/hierarchy.rb, line 155 def inherited(subclass) super @_type = nil subclass.aliased_fields = aliased_fields.dup 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
Generated with the Darkfish Rdoc Generator 2.