NAME attributes.rb INSTALL gem install attributes URIS http://rubyforge.org/projects/codeforpeople/ http://codeforpeople.com/lib/ruby SYNOPSIS attributes.rb provides a set of attr_* like method with several user friendly additions. attributes.rb is similar to the traits.rb package but sacrifices a few features for simplicity of implementation. the implementation of attributes.rb borrows many of the best ideas from the metakoans.rb ruby quiz http://www.rubyquiz.com/quiz67.html in particular the solutions of Christian Neukirchen and Florian Gross along with concepts from the original traits lib key features provided by attributes are - ability to specify default values for attrs and definition time. values can be literal objects or blocks, which are evaluated in the context of self to initialize the variable - classes remember which attributes they've defined and this information is available to client code - a whole suite of methods is defined by calls to #attributes including getter, setter, query (var?) and banger (var! - which forces re-initialization from the default value) - ability to define multiple attributes at once using key => value pairs - fast lookup of whether or not a class has defined a certain attribute - attributes can be defined on objects on a per singleton basis as well - getters acts as setters if an argument is given to them all this in < 100 lines of code HISTORY 4.0.0 - removed dependancy on, and bundle of, pervasives - faster. as fast as normal method definition. - faster lookup for MyClass.attributes.include?('foobar') 3.7.0 small patch to use 'instance_variable_defined?' instead of defined? keyword 3.5.0 migrated to a pervasives based impl to attributes should work on any object - even blankslate objects 3.3.0 moved to an instance variable-less model using an module level closure for the attributes list SAMPLES @samples