lib/helmet/api.rb in helmet-0.1.2 vs lib/helmet/api.rb in helmet-0.1.3
- old
+ new
@@ -25,10 +25,19 @@
def before_filters
@before_filters
end
+ # include methods to the helper
+ def helpers(&block)
+ @helpers.module_exec(&block)
+ end
+
+ def get_helpers
+ @helpers
+ end
+
def get(route, &block)
register_route('GET', route, &block);
register_route('HEAD', route, &block);
end
def post(route, &block) register_route('POST', route, &block); end
@@ -65,10 +74,12 @@
# Handle before filters
@before_filters = []
@config = {}
+
+ @helpers = Module.new
end
private
def setup_middlewares(klass)
@@ -83,9 +94,12 @@
# request path
path = env['REQUEST_PATH']
# request handler
handler = Handler.new(env, self.class)
+
+ # include Helpers
+ handler.extend(self.class.get_helpers)
catch(:halt) do
# evaluate filters
self.class.before_filters.each do |route|
case route.first
\ No newline at end of file