Class: Monty::Delivery
- Inherits:
-
Object
- Object
- Monty::Delivery
- Defined in:
- lib/monty/delivery.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#allowed? ⇒ true|false
If the given path and method are allowed.
-
#initialize(env) ⇒ Delivery
constructor
A new instance of Delivery.
Constructor Details
#initialize(env) ⇒ Delivery
Returns a new instance of Delivery.
14 15 16 17 18 19 20 |
# File 'lib/monty/delivery.rb', line 14 def initialize(env) @path = env['REQUEST_PATH'] || env['PATH_INFO'] @method = (env['REQUEST_METHOD'] || 'GET').to_s.downcase.to_sym @post_body = env['rack.input'] session = env['rack.session'] || {} @access_rights = session[:access_rights] || Monty::Configuration.public_access end |
Instance Attribute Details
#access_rights ⇒ Object
12 13 14 |
# File 'lib/monty/delivery.rb', line 12 def access_rights @access_rights end |
Instance Method Details
#allowed? ⇒ true|false
Returns if the given path and method are allowed.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/monty/delivery.rb', line 23 def allowed? return true if @path == '/' begin ::Authorization.configure rescue NameError end @access_rights_regex = Monty.regex(@access_rights) @path += "/" unless @path =~ /\/$/ (@access_rights_regex =~ @path && method_not_denied?) || method_match? end |