Skip to content

Instantly share code, notes, and snippets.

@VorontsovIE
Created November 10, 2012 08:08
Show Gist options
  • Save VorontsovIE/4050383 to your computer and use it in GitHub Desktop.
Save VorontsovIE/4050383 to your computer and use it in GitHub Desktop.
DCI how I want it to work
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