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
http://fhwang.net/