Class: Padrino::AuthenticityToken
- Inherits:
-
Rack::Protection::AuthenticityToken
- Object
- Rack::Protection::AuthenticityToken
- Padrino::AuthenticityToken
- Defined in:
- padrino-core/lib/padrino-core/application/authenticity_token.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #except?(env) ⇒ Boolean
-
#initialize(app, options = {}) ⇒ AuthenticityToken
constructor
A new instance of AuthenticityToken.
Constructor Details
#initialize(app, options = {}) ⇒ AuthenticityToken
Returns a new instance of AuthenticityToken.
3 4 5 6 7 8 |
# File 'padrino-core/lib/padrino-core/application/authenticity_token.rb', line 3 def initialize(app, = {}) @app = app @except = [:except] @except = Array(@except) unless @except.is_a?(Proc) super end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 |
# File 'padrino-core/lib/padrino-core/application/authenticity_token.rb', line 10 def call(env) if except?(env) @app.call(env) else super end end |
#except?(env) ⇒ Boolean
18 19 20 21 22 23 |
# File 'padrino-core/lib/padrino-core/application/authenticity_token.rb', line 18 def except?(env) return false unless @except path_info = env['PATH_INFO'] @except.is_a?(Proc) ? @except.call(env) : @except.any?{|path| path.is_a?(Regexp) ? path.match(path_info) : path == path_info } end |