Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created July 27, 2011 20:02
Show Gist options
  • Select an option

  • Save practicingruby/1110241 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/1110241 to your computer and use it in GitHub Desktop.
class Bot
def initialize(parts)
add_parts(parts)
setup
end
def add_parts(parts)
parts.each { |part| extend(part) }
end
# meant to be overrided by parts.
def setup
end
end
module PartOne
def setup
super
# do something
end
end
module PartTwo
def setup
super
# do something
end
end
bot = Bot.new(PartOne, PartTwo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment