Module: RouteHelper::ClassMethods
- Defined in:
- lib/reloj/core/route_helper.rb
Overview
maybe add link_to and button_to here
Instance Method Summary collapse
- #build_nested_route_helper(nouns) ⇒ Object
- #create_helper_method(path) ⇒ Object
- #create_helper_methods(paths) ⇒ Object
Instance Method Details
#build_nested_route_helper(nouns) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/reloj/core/route_helper.rb', line 28 def build_nested_route_helper(nouns) just_names = nouns.select { |noun| noun[0] != ":" } method_name = nouns.select do |noun| noun[0] != ":" end.join("_") + "_path" define_method(method_name) do |*ids| result = [] just_names.each do |noun| result << noun result << ids.shift unless ids.empty? end result.join('/') end end |
#create_helper_method(path) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/reloj/core/route_helper.rb', line 17 def create_helper_method(path) nouns = path.split('/') nouns.delete("") if nouns.any? { |noun| noun[0] == ":" } build_nested_route_helper(nouns) else method_name = nouns.join("_") + "_path" define_method(method_name) { path } end end |
#create_helper_methods(paths) ⇒ Object
11 12 13 14 15 |
# File 'lib/reloj/core/route_helper.rb', line 11 def create_helper_methods(paths) paths.each do |path| create_helper_method(path) end end |