Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 32 lines (20 sloc) 0.658 kb
c4901b5 @benschwarz Renamed attr_chain in all instances to remove any confusion
authored
1 # attr-chain
1fafa81 @benschwarz Added *everything*
authored
2
c4901b5 @benschwarz Renamed attr_chain in all instances to remove any confusion
authored
3 `attr-chain` is for when you're building up a `DSL` in which you'd like to have attributes
1fafa81 @benschwarz Added *everything*
authored
4 that can be chained together when they're being set.
5
c4901b5 @benschwarz Renamed attr_chain in all instances to remove any confusion
authored
6 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.
1fafa81 @benschwarz Added *everything*
authored
7
8 ## Working example
9
c4901b5 @benschwarz Renamed attr_chain in all instances to remove any confusion
authored
10 require 'attr-chain'
1fafa81 @benschwarz Added *everything*
authored
11 class Chainsaw
12 include AttributeChain
13 attr_chain :start, :cut
14 end
15
16 >> c = Chainsaw.new
17
18 >> c.start
19 => nil
20
21 >> c.start(:now).cut(:hippy)
22 >> c.start
23 => :now
24
25 >> c.cut
26 => :hippy
27
28 ### Copyright
29
30 Copyright (c) 2009 Ben Schwarz. See LICENSE for details.
31
Something went wrong with that request. Please try again.