Class: ActionDispatch::Routing::Mapper
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper
- Defined in:
- lib/accountability/rails/routes.rb
Instance Method Summary collapse
- #accountability_for(_tenants, options = {}) ⇒ Object
- #accountability_routes(options) ⇒ Object
- #default_accountability_controller_options ⇒ Object
- #default_accountability_route_options ⇒ Object
- #define_accountability_routes(options) ⇒ Object
-
#unscoped_direct(name, options = {}, &block) ⇒ Object
Mimic the functionality of Mapper#direct so that we can add a “direct” route from the cartographer proc even though we are in a scope because of #isolate_namespace.
Instance Method Details
#accountability_for(_tenants, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/accountability/rails/routes.rb', line 5 def accountability_for(_tenants, = {}) [:controllers] ||= {} [:routes] ||= {} [:controllers].reverse_merge! [:routes].reverse_merge! [:path_prefix] ||= [:path] if [:path_prefix].nil? define_accountability_routes() end |
#accountability_routes(options) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/accountability/rails/routes.rb', line 24 def accountability_routes() scope path: [:path_prefix], as: :accountability do resources :accounts, controller: .dig(:controllers, :accounts), path: .dig(:routes, :accounts) do resources :billing_configurations, controller: .dig(:controllers, :billing_configurations), path: .dig(:routes, :billing_configurations) do member { patch :designate_as_primary } end resources :payments, only: :create, controller: 'accountability/payments', path: 'payments' resources :statements, only: [], controller: 'accountability/statements', path: 'statements' do member { get :download_pdf } end end resources :products, controller: .dig(:controllers, :products), path: .dig(:routes, :products) resources :order_groups, controller: .dig(:controllers, :order_groups), path: .dig(:routes, :order_groups) do member do post :add_item put :checkout end end end unscoped_direct(:stripe_v3_javascript) { 'https://js.stripe.com/v3/' } end |
#default_accountability_controller_options ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/accountability/rails/routes.rb', line 50 def { accounts: 'accountability/accounts', products: 'accountability/products', order_groups: 'accountability/order_groups', billing_configurations: 'accountability/billing_configurations' } end |
#default_accountability_route_options ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/accountability/rails/routes.rb', line 59 def { accounts: 'accounts', products: 'products', order_groups: 'orders', billing_configurations: 'billing_configurations' } end |
#define_accountability_routes(options) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/accountability/rails/routes.rb', line 17 def define_accountability_routes() cartographer = -> { accountability_routes() } cartographer.call Accountability::Engine.routes.draw(&cartographer) end |
#unscoped_direct(name, options = {}, &block) ⇒ Object
Mimic the functionality of Mapper#direct so that we can add a “direct” route from the cartographer proc even though we are in a scope because of #isolate_namespace. github.com/rails/rails/blob/6-0-stable/actionpack/lib/action_dispatch/routing/mapper.rb#L2119-L2125
71 72 73 |
# File 'lib/accountability/rails/routes.rb', line 71 def unscoped_direct(name, = {}, &block) @set.add_url_helper(name, , &block) end |