Skip to content

Instantly share code, notes, and snippets.

@ChrisLundquist
Created October 12, 2012 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisLundquist/3879043 to your computer and use it in GitHub Desktop.
Save ChrisLundquist/3879043 to your computer and use it in GitHub Desktop.
DCI with refine, short syntax
2.0.0dev :001 > class Foo; end
=> nil
2.0.0dev :002 > class Bar; end
=> nil
2.0.0dev :003 > class Baz; end
=> nil
2.0.0dev :010 > module Runner
2.0.0dev :011?> [Foo,Bar,Baz].each do |klass|
2.0.0dev :012 > refine klass do
2.0.0dev :013 > def run
2.0.0dev :014?> puts "I am a runner"
2.0.0dev :015?> end
2.0.0dev :016?> end
2.0.0dev :017?> end
2.0.0dev :018?> end
=> [Foo, Bar, Baz]
2.0.0dev :021 > using Runner
=> main
2.0.0dev :022 > Foo.new.run
I am a runner
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment