Module: LinkedRails::Routes
- Defined in:
- lib/linked_rails/routes.rb
Instance Method Summary collapse
- #find_tenant_route ⇒ Object
-
#linked_resource(klass, controller: nil, collection: true, nested: false, resource: true, &block) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/ParameterLists.
- #singular_linked_resource(klass, controller: nil, nested: true, &block) ⇒ Object
-
#use_linked_rails(**opts) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
Instance Method Details
#find_tenant_route ⇒ Object
60 61 62 |
# File 'lib/linked_rails/routes.rb', line 60 def find_tenant_route get '_public/spi/find_tenant', to: 'linked_rails/manifests#tenant' end |
#linked_resource(klass, controller: nil, collection: true, nested: false, resource: true, &block) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/linked_rails/routes.rb', line 28 def linked_resource(klass, controller: nil, collection: true, nested: false, resource: true, &block) # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists = (klass, controller, nested, klass.route_key) if collection get([:parentable_path], to: "#{[:controller]}#index") route_block( klass, :collection, controller: [:controller], prefix: [:parentable_path] ).call end return unless resource resources( [:route_name], active_controller_opts(), &route_block(klass, :resource, &block) ) end |
#singular_linked_resource(klass, controller: nil, nested: true, &block) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/linked_rails/routes.rb', line 50 def singular_linked_resource(klass, controller: nil, nested: true, &block) = (klass, controller, nested, klass.singular_route_key) resource( [:route_name], active_controller_opts().merge(singular_route: true), &route_block(klass, :singular, &block) ) end |
#use_linked_rails(**opts) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/linked_rails/routes.rb', line 7 def use_linked_rails(**opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength constraints(LinkedRails::Constraints::Whitelist) do post 'spi/bulk', to: "#{opts.fetch(:bulk, 'linked_rails/bulk')}#show" end get '/c_a', to: "#{opts.fetch(:current_user, 'linked_rails/current_user')}#show" get '/ns/core', to: "#{opts.fetch(:ontologies, 'linked_rails/ontologies')}#show" get '/manifest', to: "#{opts.fetch(:manifests, 'linked_rails/manifests')}#show" get '/enums/:klass/:attribute', to: "#{opts.fetch(:enum_values, 'linked_rails/enum_values')}#index" get '/enums/*module/:klass/:attribute', to: "#{opts.fetch(:enum_values, 'linked_rails/enum_values')}#index" get '/forms/:id', to: "#{opts.fetch(:forms, 'linked_rails/forms')}#show" get '/forms/*module/:id', to: "#{opts.fetch(:forms, 'linked_rails/forms')}#show" get '(*parent_iri)/menus', to: "#{opts.fetch(:menus, 'linked_rails/menus')}/lists#index" get '(*parent_iri)/menus/:id', to: "#{opts.fetch(:menus, 'linked_rails/menus')}/lists#show" get '(*parent_iri)/menu_items', to: "#{opts.fetch(:menus, 'linked_rails/menus')}/items#index" get '(*parent_iri)/actions', to: "#{opts.fetch(:actions, 'linked_rails/actions')}/items#index" get '(*parent_iri)/actions/:id', to: "#{opts.fetch(:actions, 'linked_rails/actions')}/items#show" get '(*parent_iri)/action_object', to: "#{opts.fetch(:actions, 'linked_rails/actions')}/objects#show" end |