Module: Rad::CoreRoutingHelper
- Defined in:
- lib/rad/router/core/core_routing_helper.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/rad/router/core/core_routing_helper.rb', line 29
def method_missing m, *args, &block
m = m.to_s
if m =~ /_path$/
params = parse_routing_arguments(*args)
klass, method = router.encode_method m
url_for klass, method, params
else
super m.to_sym, *args, &block
end
end
|
Instance Method Details
#default_path(options = {}) ⇒ Object
7
8
9
|
# File 'lib/rad/router/core/core_routing_helper.rb', line 7
def default_path options = {}
url_for_path config.default_path!, options.merge(url_root: false)
end
|
#parse_routing_arguments(*args) ⇒ Object
18
19
20
21
22
23
24
25
26
|
# File 'lib/rad/router/core/core_routing_helper.rb', line 18
def parse_routing_arguments *args
params = args.
raise "invalid usage!" unless args.size <= 1
if args.size == 1
raise "duplicate :id pameter!" if params.include?(:id) or params.include?('id')
params[:id] = args.first.to_param
end
params
end
|
#return_to_path(options = {}) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/rad/router/core/core_routing_helper.rb', line 11
def return_to_path options = {}
dont_persist_params do
path = params[:_return_to] || workspace.request.session['return_to'] || config.default_path!
url_for_path path, options.merge(url_root: false)
end
end
|