lib/rails/routing_mapper.rb in para-0.5.1 vs lib/rails/routing_mapper.rb in para-0.5.3
- old
+ new
@@ -18,11 +18,15 @@
as, controller, endpoint = component_informations_from(
component_name, options
)
get endpoint => "#{ controller }#show", as: as
- scope(endpoint, as: component_name, &block) if block
+
+ scope(endpoint, as: component_name) do
+ instance_eval(&block) if block
+ add_extensions_for(:component)
+ end
end
def crud_component(component_name, options = {}, &block)
as, controller, endpoint = component_informations_from(
component_name, options
@@ -43,10 +47,11 @@
member do
post :clone
end
instance_eval(&block) if block
+ add_extensions_for(:crud_component)
end
end
end
end
@@ -57,10 +62,11 @@
controller = [component_name, 'resources'].join('_')
scope endpoint, as: as do
resource :resource, controller: controller, only: [:show, :create, :update]
+ add_extensions_for(:singleton_resource_component)
end
end
private
@@ -78,9 +84,15 @@
as = options.fetch(:as, component_name)
controller = options.fetch(:controller, "#{ component_name }_component")
endpoint = "#{ path }/:component_id"
[as, controller, endpoint]
+ end
+
+ def add_extensions_for(type)
+ Para.config.routes.routes_extensions_for(type).each do |extension|
+ instance_eval(&extension)
+ end
end
end
end
end