Class: ActionController::Routing::RouteSet::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_routes.rb

Overview

module ActionController

module Routing
  module RouteSet
  end
end

end

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(route_name, *args, &proc) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/easy_routes.rb', line 9

def method_missing(route_name, *args, &proc)
  #puts "route_name: #{route_name}"
  #puts "args: #{args}"
  if args.first.is_a? String
    return h_method_missing(route_name, *args, &proc)
  end
  cont = args.first[:controller]
  act = args.first[:action] || route_name.to_s
  r_name = "#{cont}/#{act}"
  r_name += "/:id" unless args.first[:id] == false
  ags = []
  h_method_missing("#{cont}_#{route_name}", r_name, {:controller => cont, :action => act})
end

Instance Method Details

#defaults(*args) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/easy_routes.rb', line 28

def defaults(*args)
  [{:action => "index", :id => false},
   {:action => "list", :id => false},
   {:action => "new", :id => false},
   {:action => "create", :id => false},
   {:action => "show"}, {:action => "edit"},
   {:action => "update"}, {:action => "destroy"}].each do |ag|
     ag.merge!(args.first)
     eval "self.#{ag[:action]} ag"
   end
end

#h_method_missing(route_name, *args, &proc) ⇒ Object



23
24
25
26
# File 'lib/easy_routes.rb', line 23

def h_method_missing(route_name, *args, &proc)
  super unless args.length >= 1 && proc.nil?
  @set.add_named_route(route_name, *args)
end