Sha256: 5697f87538d6114dbc25bac9412fbd76255e7d899b4d90a691bd1b32574a002c
Contents?: true
Size: 900 Bytes
Versions: 1
Compression:
Stored size: 900 Bytes
Contents
module Virtus # A module that adds descendant tracking to a class module DescendantsTracker # Return the descendants of this class # # @return [Array<Class>] # # @api private def descendants @descendants ||= [] end # Add the descendant to this class and the superclass # # @param [Class] descendant # # @return [self] # # @api private def add_descendant(descendant) superclass = self.superclass superclass.add_descendant(descendant) if superclass.respond_to?(:add_descendant) descendants.unshift(descendant) self end private # Hook called when class is inherited # # @param [Class] descendant # # @return [self] # # @api private def inherited(descendant) super add_descendant(descendant) end end # module DescendantsTracker end # module Virtus
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
virtus-0.0.5 | lib/virtus/support/descendants_tracker.rb |