Class: Hemp::Routing::Route
Instance Attribute Summary collapse
-
#controller_action ⇒ Object
readonly
Returns the value of attribute controller_action.
-
#regex_match ⇒ Object
readonly
Returns the value of attribute regex_match.
-
#url_variables ⇒ Object
readonly
Returns the value of attribute url_variables.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #action ⇒ Object
- #action_sym ⇒ Object
- #controller ⇒ Object
- #controller_camel ⇒ Object
- #controller_class ⇒ Object
- #controller_snake ⇒ Object
- #get_url_vars(path_info) ⇒ Object
-
#initialize(controller_action, regex_match, url_variables = {}) ⇒ Route
constructor
A new instance of Route.
Constructor Details
#initialize(controller_action, regex_match, url_variables = {}) ⇒ Route
Returns a new instance of Route.
8 9 10 11 12 |
# File 'lib/hemp/routing/route.rb', line 8 def initialize(controller_action, regex_match, url_variables = {}) @controller_action = controller_action.split("#") @regex_match = regex_match @url_variables = url_variables end |
Instance Attribute Details
#controller_action ⇒ Object (readonly)
Returns the value of attribute controller_action.
6 7 8 |
# File 'lib/hemp/routing/route.rb', line 6 def controller_action @controller_action end |
#regex_match ⇒ Object (readonly)
Returns the value of attribute regex_match.
6 7 8 |
# File 'lib/hemp/routing/route.rb', line 6 def regex_match @regex_match end |
#url_variables ⇒ Object (readonly)
Returns the value of attribute url_variables.
6 7 8 |
# File 'lib/hemp/routing/route.rb', line 6 def url_variables @url_variables end |
Instance Method Details
#==(other) ⇒ Object
48 49 50 |
# File 'lib/hemp/routing/route.rb', line 48 def ==(other) (regex_match =~ other) == 0 end |
#action ⇒ Object
18 19 20 |
# File 'lib/hemp/routing/route.rb', line 18 def action @controller_action[1] end |
#action_sym ⇒ Object
30 31 32 |
# File 'lib/hemp/routing/route.rb', line 30 def action_sym action.to_sym end |
#controller ⇒ Object
14 15 16 |
# File 'lib/hemp/routing/route.rb', line 14 def controller @controller_action[0] end |
#controller_camel ⇒ Object
26 27 28 |
# File 'lib/hemp/routing/route.rb', line 26 def controller_camel controller_class.camelcase :upper end |
#controller_class ⇒ Object
22 23 24 |
# File 'lib/hemp/routing/route.rb', line 22 def controller_class controller + "_controller" end |
#controller_snake ⇒ Object
34 35 36 |
# File 'lib/hemp/routing/route.rb', line 34 def controller_snake controller_class.snakecase end |
#get_url_vars(path_info) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/hemp/routing/route.rb', line 38 def get_url_vars(path_info) path_elements = path_info.split("/") var_collection = {} url_variables.each_key do |index| var_collection[url_variables[index]] = path_elements[index] end var_collection end |