module RailsNavigation::Matcher
Public Class Methods
check_action(action_name, str)
click to toggle source
# File lib/rails_navigation/matcher.rb, line 8 def self.check_action(action_name, str) result = Array(str.match(/#([a-z_\-]+)/))[1] result ? (result == action_name) : true end
check_controller(controller_name, str)
click to toggle source
# File lib/rails_navigation/matcher.rb, line 3 def self.check_controller(controller_name, str) result = Array(str.match(/^([a-z_\-]+)/))[1] result ? (result == controller_name) : true end
check_parameters(params, str)
click to toggle source
# File lib/rails_navigation/matcher.rb, line 13 def self.check_parameters(params, str) result = Array(str.match(/\?([!a-z0-9&_\-=]+)/))[1] if result key, value = result.split('=') result.include?('=') ? value == params[key.to_sym] : result == params[:id] else true end end
match_multiple_with_or?(controller_name, action_name, params, arr)
click to toggle source
# File lib/rails_navigation/matcher.rb, line 27 def self.match_multiple_with_or?(controller_name, action_name, params, arr) [*arr].any? { |str| match_single?(controller_name, action_name, params, str) } end
match_single?(controller_name, action_name, params, str)
click to toggle source
# File lib/rails_navigation/matcher.rb, line 23 def self.match_single?(controller_name, action_name, params, str) check_controller(controller_name, str) && check_action(action_name, str) && check_parameters(params, str) end