Skip to content

Instantly share code, notes, and snippets.

@dorkalev
Last active August 29, 2015 13:57
Show Gist options
  • Save dorkalev/9923752 to your computer and use it in GitHub Desktop.
Save dorkalev/9923752 to your computer and use it in GitHub Desktop.
trying modules instead of classes for the actions
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