public
Description: attr_chain for chainable, single method attribute (get|setters)
Homepage:
Clone URL: git://github.com/benschwarz/attr-chain.git
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 Sun Jun 07 19:12:19 -0700 2009 Renamed attr_chain in all instances to remove a... [benschwarz]
file Rakefile Fri Jun 05 06:14:13 -0700 2009 Updated the gem name for github generation [benschwarz]
file VERSION.yml Sun Jun 07 19:12:41 -0700 2009 Version bump to 0.1.2 [benschwarz]
file attr-chain.gemspec Sun Jun 07 19:12:45 -0700 2009 Regenerated gemspec for version 0.1.2 [benschwarz]
directory lib/ Sun Jun 07 19:12:19 -0700 2009 Renamed attr_chain in all instances to remove a... [benschwarz]
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.