Created
September 5, 2011 10:00
-
-
Save bblimke/1194608 to your computer and use it in GitHub Desktop.
DCI in Ruby
This file contains hidden or 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
class Person | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end | |
end | |
person = Person.new("Trygve Reenskaug") | |
module Buyer | |
def buy(item) | |
# buying logic | |
end | |
end | |
module FootballPlayer | |
def kick_ball(ball) | |
# kicking ball logic | |
end | |
def run | |
# running logic | |
end | |
end | |
def FootballGameContext | |
person.mixin FootballPlayer | |
person.run | |
person.kick_ball(ball) | |
person.unmix FootballPlayer | |
end | |
def ShopContext | |
person.mixin Buyer | |
person.buy(milk) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment