Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[ANN] Updateable 0.0.3

0 views
Skip to first unread message

John W. Long

unread,
May 3, 2005, 11:56:41 PM5/3/05
to
This is the first public release of a very, very small project I've been
developed at work. I call it Updateable. By mixing in the Updateable
module into a class you can easily update the attributes of the class
with a hash:

require 'updateable'

class TestObject
include Updateable

attr_accessor :a, :b, :c

def initialize(options = {})
update(options)
end
end

o = TestObject.new(:a => 1, :b => 2, :c => 3)
puts "#{o.a}#{o.b}#{o.c}" #=> '123'

o.update(:a => 'a', :b => 'b', :c => 'c')
puts "#{o.a}#{o.b}#{o.c}" #=> 'abc'

Download:
http://johnwlong.com/downloads/iblp-mixins-0.0.3/lib/updateable.rb

Tests:
http://johnwlong.com/downloads/iblp-mixins-0.0.3/test/unit/updateable_test.rb

Updateable is currently part of another small project which can be
downloaded here:

http://johnwlong.com/downloads/iblp-mixins-0.0.3.tgz

--
John Long
http://wiseheartdesign.com

Francis Hwang

unread,
May 8, 2005, 10:55:13 AM5/8/05
to
Interesting. Is there a particular kind of use that inspired you to
write this module? Or is it just that you'd rather condense four lines
of attribute assignment into one?

Francis Hwang
http://fhwang.net/

0 new messages