Overview

ATTRIBUTE-DRIVEN
by Aman King

http://bitbucket.org/amanking/attribute-driven/

A module that 
(1) allows you to mention a list of attributes in a class, 
(2) provides reader methods for the attributes, 
(3) allows initialization of the class via a hash argument that gives values for the attributes,
(4) overrides equals and hash method to check for field equality 

Usage:

require 'attribute_driven'
class Money
  include AttributeDriven
  attributes :value, :currency
  # initializes_with :value, :currency #=> only adds the initialize method
  # equality_based_on :value, :currency #=> only overrides equality methods and hash
end

money = Money.new(:value => 20, :currency => 'USD') #=> #<Money:0x5138e4 @value=20, @currency="USD">
money.value #=> 20
money.currency #=> "USD"
money == Money.new(:value => 20, :currency => 'USD') #=> true

(see test/attribute_driven_test.rb for more)

License

   Copyright 2009 Aman King

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.