J
John W. Long
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
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
puts "#{o.a}#{o.b}#{o.c}" #=> '123'
o.update
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