Skip to content

Instantly share code, notes, and snippets.

@towry
Created June 6, 2015 14:43
Show Gist options
  • Save towry/b43e2ac3d71baaa9e66d to your computer and use it in GitHub Desktop.
Save towry/b43e2ac3d71baaa9e66d to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# -*- encoding: UTF-8 -*-
class Base
attr_reader :blocks
class << self
def get(path, &block)
@blocks ||= []
@blocks << block
end
def reset!
@blocks = []
end
def run
@blocks.each do |bk|
bk.call
end
end
end
def self.inherited(subclass)
subclass.reset!
end
reset!
end
class Application < Base
get '/' do
puts "hi"
end
end
if __FILE__ == $0
Application.run
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment