Sha256: ce19fb5b8cd77e7cbe08a3c0ba53ff8f0d91d1e4f0c886909699d9244b3de165

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

# encoding: UTF-8
require 'set'

module MongoMapper
  module Support
    module DescendantAppends
      def included(model = nil, &block)
        if model
          extra_extensions.each { |extension| model.extend(extension) }
          extra_inclusions.each { |inclusion| model.send(:include, inclusion) }
          direct_descendants << model
        end
        super
      end

      # @api public
      def append_extensions(*extensions)
        warn "[DEPRECATED] append_extensions is deprecated. Use #plugin with a module that extends ActiveSupport::Concern."
        extra_extensions.concat(extensions)
        direct_descendants.each do |model|
          extensions.each { |extension| model.extend(extension) }
        end
      end

      # @api public
      def append_inclusions(*inclusions)
        warn "[DEPRECATED] append_inclusions is deprecated. Use #plugin with a module that extends ActiveSupport::Concern."
        extra_inclusions.concat(inclusions)
        direct_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

3 entries across 3 versions & 1 rubygems

Version Path
mongo_mapper-0.9.2 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-0.9.1 lib/mongo_mapper/support/descendant_appends.rb
mongo_mapper-0.9.0 lib/mongo_mapper/support/descendant_appends.rb