Project

attr-chain

0.0
No commit activity in last 3 years
No release in over 3 years
attr_chain for chainable, single method attribute (get|setters)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

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.