public
Description: attr_chain for chainable, single method attribute (get|setters)
Homepage:
Clone URL: git://github.com/benschwarz/attr-chain.git
benschwarz (author)
Sun Jun 07 19:12:41 -0700 2009
commit  e9b4679be5e6f7afab21ac24a78fe2374ec720c2
tree    2c96b798e4a10d95497e200d0e5e60d362f76029
parent  c4901b53f2d973c17595eec0b4b140bfe7971d52
name age message
file .document Fri Jun 05 02:19:35 -0700 2009 Initial commit to attr_method. [benschwarz]
file .gitignore Fri Jun 05 02:19:35 -0700 2009 Initial commit to attr_method. [benschwarz]
file LICENSE Fri Jun 05 02:19:35 -0700 2009 Initial commit to attr_method. [benschwarz]
file README.md Loading commit data...
file Rakefile
file VERSION.yml Sun Jun 07 19:12:41 -0700 2009 Version bump to 0.1.2 [benschwarz]
file attr-chain.gemspec
directory lib/
directory spec/ Fri Jun 05 06:04:17 -0700 2009 Added *everything* [benschwarz]
README.md

attr-chain

attr-chain is for when you're building up a DSL in which you'd like to have attributes that can be chained together when they're being set.

Its simple and small, you probably aren't interested. I kept on using this pattern and wanted to abstract it away from my other code.

Working example

require 'attr-chain'
class Chainsaw
  include AttributeChain
  attr_chain :start, :cut
end

>> c = Chainsaw.new

>> c.start 
=> nil

>> c.start(:now).cut(:hippy)
>> c.start 
=> :now

>> c.cut
=> :hippy

Copyright

Copyright (c) 2009 Ben Schwarz. See LICENSE for details.