Sha256: 0a0c55353560c063be6099f720c07d2b8be3a966a21947051e9f8b61d7f025f9

Contents?: true

Size: 1.04 KB

Versions: 60

Compression:

Stored size: 1.04 KB

Contents

# encoding: UTF-8
require 'set'

module MongoMapper
  module Support
    module DescendantAppends
      def included(model)
        extra_extensions.each { |extension| model.extend(extension) }
        extra_inclusions.each { |inclusion| model.send(:include, inclusion) }
        descendants << model
      end

      # @api public
      def descendants
        @descendants ||= Set.new
      end

      # @api public
      def append_extensions(*extensions)
        extra_extensions.concat(extensions)
        descendants.each do |model|
          extensions.each { |extension| model.extend(extension) }
        end
      end

      # @api public
      def append_inclusions(*inclusions)
        extra_inclusions.concat(inclusions)
        descendants.each do |model|
          inclusions.each { |inclusion| model.send(:include, inclusion) }
        end
      end

      # @api private
      def extra_extensions
        @extra_extensions ||= []
      end

      # @api private
      def extra_inclusions
        @extra_inclusions ||= []
      end
    end
  end
end

Version data entries

60 entries across 60 versions & 7 rubygems

Version Path
mongo_mapper-unstable-2010.07.15 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.07.14 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.07.13 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.07.12 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.07.09 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.07.08 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.07.07 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.07.06 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.07.05 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.07.02 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.07.01 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.06.30 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.06.29 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.06.28 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.06.25 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.06.24 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-unstable-2010.06.23 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-0.8.2 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-0.8.1 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-0.8.0 lib/mongo_mapper/support/descendant_appends.rb