Anyway, it looks to me like some combination of .clone plus a factory.
I’m not sure there’s any real savings in Ruby to doing things this way,
but I’d be happy to be proved wrong.
Regards,
Dan
This communication is the property of Qwest and may contain confidential
or
privileged information. Unauthorized use of this communication is
strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and
destroy
all copies of the communication and any attachments.
Anyway, it looks to me like some combination of .clone plus a factory. I’m
not sure there’s any real savings in Ruby to doing things this way, but I’d
be happy to be proved wrong.
hi daniel-
savings is only keystrokes. but it can very elegant looking and, these
days,
ruby coding bores me unless it looks good too - solving problems is just
too
easy in it to provide enough challenge! take this code for
example:
fortytwo :~/eg/ruby/prototype > cat a.rb
require 'prototype'
singleton = Prototype.new{
@a, @b = 40, 2
def answer() @a + @b end
}
p singleton.answer
fortytwo :~/eg/ruby/prototype > ruby a.rb
42
fortytwo :~/eg/ruby/prototype > cat b.rb
require 'prototype'
DB = Prototype.new{
host 'localhost'
port 4242
def connect() 'do something' end
def inspect() [host, port].join ':' end
}
p DB
p DB.host
p DB.port
fortytwo :~/eg/ruby/prototype > ruby b.rb
localhost:4242
"localhost"
4242