Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created January 11, 2012 20:56
Show Gist options
  • Select an option

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

Select an option

Save practicingruby/1596723 to your computer and use it in GitHub Desktop.
class Application
def initialize
@commands = {}
end
def command(name, &callback)
@commands[name] = callback
end
def run(name)
@commands[name].call
end
end
app = Application.new
app.command(:hello) do
puts "hello"
end
app.command(:goodbye) do
puts "goodbye"
end
app.run(:hello)
app.run(:goodbye)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment