There have been many attempts to rewrite attr_accessor to support default values; the best attempt so far (in my opinion) is schmidt’s ‘attr_accessor on steroids’. attr++ is an extension of schmidt’s work to support the initialization of multiple attributes on a single line. The syntax is as follows:
attr_plus_plus {x 20; y "hello"; z 1, 2, [...]
Filed under: metaprogramming, programming, ruby | Tagged: attr_accessor, attr_accessor default values, dsl, meta-programming, ruby | Leave a Comment »