Class: ActionDispatch::Routing::Mapper
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper
- Defined in:
- lib/rails/routing_mapper.rb
Instance Method Summary collapse
- #component(component_name, options = {}, &block) ⇒ Object
- #crud_component(component_name, options = {}, &block) ⇒ Object
- #para_at(mount_location, &block) ⇒ Object
- #para_plugin(plugin_name) ⇒ Object
- #singleton_resource_component(component_name, options = {}, &block) ⇒ Object
Instance Method Details
#component(component_name, options = {}, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rails/routing_mapper.rb', line 17 def component(component_name, = {}, &block) as, controller, endpoint = component_informations_from( component_name, ) get endpoint => "#{ controller }#show", as: as scope(endpoint, as: component_name) do instance_eval(&block) if block add_extensions_for(:component) end end |
#crud_component(component_name, options = {}, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rails/routing_mapper.rb', line 30 def crud_component(component_name, = {}, &block) as, controller, endpoint = component_informations_from( component_name, ) controller = [component_name.to_s.singularize, 'resources'].join('_') scope endpoint, as: as do scope [:scope] do resources :resources, controller: controller do collection do patch :order patch :tree get :export post :import end member do post :clone end instance_eval(&block) if block add_extensions_for(:crud_component) end end end end |
#para_at(mount_location, &block) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/rails/routing_mapper.rb', line 4 def para_at(mount_location, &block) Para::Routes.new(self).draw(mount_location, &block) Para::Config.plugins.each do |plugin| draw_plugin_routes(plugin) end end |
#para_plugin(plugin_name) ⇒ Object
12 13 14 15 |
# File 'lib/rails/routing_mapper.rb', line 12 def para_plugin(plugin_name) routes = ['', plugin_name.to_s.camelize, 'Routes'].join('::').constantize routes.new(self).draw end |
#singleton_resource_component(component_name, options = {}, &block) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rails/routing_mapper.rb', line 58 def singleton_resource_component(component_name, = {}, &block) as, _, endpoint = component_informations_from( component_name, ) 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 |