class Algernon::Routing::Finder
Attributes
action[R]
controller_name[R]
path_regex[R]
url_placeholders[R]
Public Class Methods
new(path_regex, to, url_placeholders = {})
click to toggle source
# File lib/algernon/routing/finder.rb, line 5 def initialize(path_regex, to, url_placeholders = {}) @controller_name, @action = get_controller_and_action(to) @path_regex = path_regex @url_placeholders = url_placeholders end
Public Instance Methods
==(other)
click to toggle source
# File lib/algernon/routing/finder.rb, line 28 def ==(other) controller_name == other.controller_name && action == other.action && path_regex == other.path_regex && url_placeholders == other.url_placeholders end
check_path(path)
click to toggle source
# File lib/algernon/routing/finder.rb, line 24 def check_path(path) (path_regex =~ path) == 0 end
controller()
click to toggle source
# File lib/algernon/routing/finder.rb, line 11 def controller Object.const_get(controller_name.camelify) end
get_url_parameters(actual_path)
click to toggle source
# File lib/algernon/routing/finder.rb, line 15 def get_url_parameters(actual_path) parameters = {} path = actual_path.split("/") url_placeholders.each do |index, key| parameters[key] = path[index.to_i] end parameters end
Private Instance Methods
get_controller_and_action(to)
click to toggle source
# File lib/algernon/routing/finder.rb, line 37 def get_controller_and_action(to) controller, action = to.split("#") controller_name = controller + "_controller" [controller_name, action] end