Last active
August 29, 2015 13:57
-
-
Save dorkalev/9923752 to your computer and use it in GitHub Desktop.
trying modules instead of classes for the actions
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 Action | |
end | |
module Carry | |
include Action | |
end | |
module ShowOff | |
include Action | |
end | |
module Travel | |
include Action | |
end | |
class Vehicle | |
def capable_of?(x) | |
puts self.ancestors.include?(x) | |
end | |
end | |
class Car < Vehicle | |
include Travel | |
end | |
class Truck < Vehicle | |
include Travel | |
include ShowOff | |
end | |
Car.capable_of?(Travel) | |
Car.capable_of?(ShowOff) | |
Truck.capable_of?(ShowOff) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment