Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Detect and load specific rack up extensions.

  • Loading branch information...
commit 217bf4aa4b7613903ecf69894548c243cc6f1902 1 parent 14aa8f6
Piotr Murach authored
Showing with 22 additions and 0 deletions.
  1. +4 −0 lib/rack/policy.rb
  2. +18 −0 lib/rack/policy/extensions.rb
4 lib/rack/policy.rb
View
@@ -7,6 +7,10 @@ module Policy
autoload :CookieLimiter, 'rack/policy/cookie_limiter'
autoload :Version, 'rack/policy/version'
+ autoload :Helpers, 'rack/policy/helpers'
+
+ # Initialize Rack::Policy extensions within an application
+ require 'rack/policy/extensions'
end # Policy
end # Rack
18 lib/rack/policy/extensions.rb
View
@@ -0,0 +1,18 @@
+# -*- encoding: utf-8 -*-
+
+# Autoload Rails extensions
+if defined?(Rails) && Rails.respond_to?(:application)
+ # Rails 3
+ require 'rack/policy/railtie'
+
+elsif defined?(Rails::Initializer)
+ # Rails 2.3
+ require 'action/view/base'
+
+ ActionView::Base.send :include, Rack::Policy::Helpers
+elsif defined?(Sinatra)
+ require 'rack/policy/sinatra'
+
+elsif defined?(Padrino)
+ require 'padrino-core'
+end
Please sign in to comment.
Something went wrong with that request. Please try again.