Module: Multiton::Inclusive
- Included in:
- Multiton, MetaMethods
- Defined in:
- lib/standard/facets/multiton.rb
Overview
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.
–
def append_features(mod)
# help out people counting on transitive mixins
unless mod.instance_of?(Class)
raise TypeError, "Inclusion of Multiton in module #{mod}"
end
super
end
++
Instance Method Summary collapse
- #included(base) ⇒ Object private
Instance Method Details
#included(base) ⇒ Object (private)
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/standard/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 |