Created
November 10, 2012 08:08
-
-
Save VorontsovIE/4050383 to your computer and use it in GitHub Desktop.
DCI how I want it to work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BadFlyer | |
def fly | |
puts 'Not a chance' | |
false | |
end | |
end | |
module Runner | |
def run | |
puts 'Run, #{self}! Run!' | |
end | |
end | |
class User; end | |
man = User.new | |
class Penguin; end | |
tux = Penguin.new | |
use(man).as(Runner) do |runner| | |
runner.run | |
end | |
use(tux).as(Runner, BadFlyer) do |funny_runner| | |
puts 'Lets try...' | |
funny_runner.fly || funny_runner.run | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment