Class: Simple::Authorisation::ExactRouteRuleFinder

Inherits:
RouteRuleFinder show all
Defined in:
lib/simple-authorisation/exact_route_rule_finder.rb

Instance Method Summary collapse

Methods inherited from RouteRuleFinder

#find, #route_by_wild_card, #route_starts_with

Constructor Details

#initialize(routes) ⇒ ExactRouteRuleFinder

Returns a new instance of ExactRouteRuleFinder.



6
7
8
9
# File 'lib/simple-authorisation/exact_route_rule_finder.rb', line 6

def initialize(routes)
  super(routes)
  @find_by = [:route_by_wild_card, :route_matches]
end

Instance Method Details

#route_matches(route_name) ⇒ Object



11
12
13
14
# File 'lib/simple-authorisation/exact_route_rule_finder.rb', line 11

def route_matches(route_name)
  route_name = URI.parse(route_name).path.gsub(/\/$/, '')
  (@routes.keys.sort.reverse.select { |route| route =~ /#{route_name}\/?/ }).first
end