Class: CanCanDry::PathRecognizer
- Inherits:
-
Object
- Object
- CanCanDry::PathRecognizer
- Defined in:
- lib/can_can_dry/path_recognizer.rb
Overview
Copiado de github.com/appirits/awesome_admin_layout /lib/awesome_admin_layout/recognize_path.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.recognize(root_path, path, options = {}) ⇒ Object
10 11 12 |
# File 'lib/can_can_dry/path_recognizer.rb', line 10 def recognize(root_path, path, = {}) new(root_path, path, ).recognize_or_raise end |
.remove_root_path(root_path, path) ⇒ Object
14 15 16 17 |
# File 'lib/can_can_dry/path_recognizer.rb', line 14 def remove_root_path(root_path, path) path = path.gsub(/\A#{Regexp.quote(root_path)}/, '') path.gsub(%r{\A/*}, '/') end |
Instance Method Details
#recognize ⇒ Object
28 29 30 |
# File 'lib/can_can_dry/path_recognizer.rb', line 28 def recognize core_recognize || engines_recognize end |
#recognize_or_raise ⇒ Object
24 25 26 |
# File 'lib/can_can_dry/path_recognizer.rb', line 24 def recognize_or_raise recognize || raise("Path not recognized: \"#{path}\" (Options: #{})") end |