[ANN] Facets / Multiton 2.0.0

T

Trans

Facets / Multiton 2.0.0

Implementation of the Multiton Design Pattern

by Ara T Howard and Trans

http://facets.rubyforge.org


[ S Y N O P S I S ]

Multiton is similar to the Singleton, but rather than a single object
it pools a cached set corresponding to the initialization parameters,
ie. initialize the class again with the same parameters and get the
same object.


[ I N S T A L L ]

Please note Facets/Multiton is already included in the complete Facets
package. You do not need this if you already have Facets installed.
You can install this library via gem or tarball. Eg.

gem install facets_multition

or

wget http://rubyforge.org/frs/download.php/18259/facets_multiton-2.0.0.tgz
tar -xvzf facets_multiton-2.0.0.tgz
cd facets_multiton-2.0.0
sudo ruby setup.rb


[ C R E D I T ]

Ara T. Howard (Original Code)
Trans (Improvements)


[ L I C E N S E ]

Facets/Multiton
Copyright (c) 2005-2007 Ara T. Howard, Trans
All Right Reserved

Distributed under the terms of the Ruby/GPL license.
 
A

ara.t.howard

[ C R E D I T ]

Ara T. Howard (Original Code)
Trans (Improvements)
^^^^^^^^^^^^
^^^^^^^^^^^^
^^^^^^^^^^^^ undoubtedly, the code was bit rotting, but what?

cheers.

-a
 
T

Trans

[ C R E D I T ]
Ara T. Howard (Original Code)
Trans (Improvements)

^^^^^^^^^^^^
^^^^^^^^^^^^
^^^^^^^^^^^^ undoubtedly, the code was bit rotting, but what?


Most notably and interface change. From the docs:

# == Previous Behavior
#
# In previous versions of Multiton the #new method was made
# private and #instance was used in its stay --just like Singleton.
# But this has proved less desirable for Multiton since Multitions can
# have multiple instances, not just one.
#
# So instead Multiton now defines #create as a private alias of
# the original #new method (just in case it is needed) and then
# defines #new to handle the multiton, and #instance is provided
# as an alias for it.
#
# If you must have the old behavior, all you need do is re-alias
# #new to #create and privatize it.
#
# class SomeMultitonClass
# include Multiton
# alias_method :new, :create
# private :new
# ...
# end
#
# Then only #instance will be available for creating the Multiton.

Another example:

k = begin
Marshal.dump(k)
rescue TypeError
k
end

k is the args passed to the initializer, but marshalled to use as a
hash key for caching.

Also, I simplied how the METHOD_NEW_HOOK is used so that it is always
defined.

Think that's about it.

T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

[ANN] Facets / Annotations 2.0.0 1
ANN: Facets 2.0 12
[ANN] Facets 1.8 4
[ANN] Ruby Facets 0.6.3 0
[ANN] Sipper 2.0.0 Released 1
[ANN] Dfect 2.0.0 (2010-03-21) 0
[ANN] wxRuby 2.0.0 9
[ANN] Facets 2005-10-30 9

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top