module Multiton::Inclusive

Multiton can be included in another module, in which case that module effectively becomes a multiton behavior distributor too. This is why we propogate included to the base module by putting it in another module.

Private Instance Methods

included(base) click to toggle source
# File lib/facets/multiton.rb, line 189
def included(base)
  class << base
    ##alias_method(:new!, :new) unless method_defined?(:new!)
    ## gracefully handle multiple inclusions of Multiton
    unless include?(Multiton::MetaMethods)
      alias_method :new!, :new
      private :allocate #, :new
      include Multiton::MetaMethods

      if method_defined?(:marshal_dump)
        undef_method :marshal_dump
        warn "warning: marshal_dump was undefined since it is incompatible with the Multiton pattern"
      end
    end
  end
end