Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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