Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (20 sloc) 658 Bytes


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

>> c =

>> c.start 
=> nil

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

>> c.cut
=> :hippy


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