Module: ActionDispatch::Routing::Mapper::Base

Defined in:
lib/active_scaffold/extensions/routing_mapper.rb

Instance Method Summary collapse

Instance Method Details

#as_association_routesObject



24
25
26
27
28
29
30
31
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 24

def as_association_routes
  collection do 
    ActionDispatch::Routing::ACTIVE_SCAFFOLD_ASSOCIATION_ROUTING[:collection].each {|name, type| send(type, name)}
  end
  member do
    ActionDispatch::Routing::ACTIVE_SCAFFOLD_ASSOCIATION_ROUTING[:member].each {|name, type| send(type, name)}
  end
end

#as_nested_resources(*resources) ⇒ Object



33
34
35
36
37
38
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 33

def as_nested_resources(*resources)
  options = resources.extract_options!
  resources.each do |resource|
    resources(resource, options.merge(:parent_scaffold => merge_module_scope(@scope[:module], parent_resource.plural), :association => resource)) { yield if block_given? }
  end
end

#as_routes(options = {:association => true}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 13

def as_routes(options = {:association => true})
  collection do
    ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection].each {|name, type| match(name, :via => type)}
  end
  member do
    ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:member].each {|name, type| match(name, :via => type)}
    get 'list', :action => :index
  end
  as_association_routes if options[:association]
end

#as_scoped_routes(*scopes) ⇒ Object



40
41
42
43
44
45
# File 'lib/active_scaffold/extensions/routing_mapper.rb', line 40

def as_scoped_routes(*scopes)
  options = scopes.extract_options!
  scopes.each do |scope|
    resources(scope, options.merge(:parent_scaffold => merge_module_scope(@scope[:module], parent_resource.plural), :named_scope => scope, :controller => parent_resource.plural)) { yield if block_given? }
  end
end