Class: Lockdown::Delivery

Inherits:
Object
  • Object
show all
Defined in:
lib/lockdown/delivery.rb

Class Method Summary collapse

Class Method Details

.allowed?(path, access_rights = nil) ⇒ true|false

Returns if the given path is allowed.

Returns:

  • (true|false)

    if the given path is allowed



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/lockdown/delivery.rb', line 7

def allowed?(path, access_rights = nil)
  return true if path == '/'

  begin
    ::Authorization.configure
  rescue NameError
  end

  access_rights ||= Lockdown::Configuration.public_access

  access_rights_regex = Lockdown.regex(access_rights)

  path += "/" unless path =~ /\/$/
  path = "/" + path unless path =~ /^\//
  
  access_rights_regex =~ path ? true : false
end