55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/puffer/extensions/mapper31.rb', line 55
def resource_scope_with_puffer resource, &block
controller = "#{[@scope[:module], resource.controller].compact.join("/")}_controller".camelize.constantize rescue nil
if controller && controller.puffer?
singular = resource.is_a? ActionDispatch::Routing::Mapper::Resources::SingletonResource
name = (singular ? resource.singular : resource.plural).to_sym
resource_node = ::Rails.application.routes.resources_tree.append_node swallow_nil{@scope[:defaults][:puffer]},
:name => name, :scope => @scope[:module].to_sym, :controller => controller, :singular => singular
defaults :puffer => resource_node do
resource_scope_without_puffer resource do
block.call if block
member do
controller._members.each do |action|
send *action.route
end
end
collection do
controller._collections.each do |action|
send *action.route
end
get '/event/:fieldset/:field/:event(/:identifer)', :action => :event, :as => :event
end
end
end
else
resource_scope_without_puffer resource, &block
end
end
|