Class: Stall::Routes

Inherits:
Object
  • Object
show all
Defined in:
lib/stall/routes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(router) ⇒ Routes

Returns a new instance of Routes.



5
6
7
# File 'lib/stall/routes.rb', line 5

def initialize(router)
  @router = router
end

Instance Attribute Details

#routerObject (readonly)

Returns the value of attribute router.



3
4
5
# File 'lib/stall/routes.rb', line 3

def router
  @router
end

Instance Method Details

#draw(mount_location) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/stall/routes.rb', line 9

def draw(mount_location)
  router.instance_eval do
    scope mount_location, module: :stall do
      resources :carts do
        resources :line_items
      end

      get 'checkout/:cart_key' => 'checkouts#show', as: :checkout

      scope 'checkout', module: 'checkout', as: :checkout do
        scope '(:cart_key)' do
          resource :step, only: [:show, :update] do
            post '/', action: :update, as: :update
            get '/process', action: :update, as: :process
            get 'change/:step', action: :change, as: :change
          end
        end
      end


      scope '/:gateway' do
        resource :payment, only: [] do
          member do
            match 'notify', action: 'notify', via: [:get, :post]
          end
        end
      end
    end
  end
end