Sha256: 4c53963f7bca13018c3c8edfdfdeb0b1d34ca24d08eb95a8adc3bc67d2f5a485

Contents?: true

Size: 819 Bytes

Versions: 2

Compression:

Stored size: 819 Bytes

Contents

module Pakyow
  module Routes
    module Restful
      include Pakyow::Routes

      template :restful do
        resource_id = ":#{@group}_id"

        nested_path { |path| File.join(path, resource_id) }
        view_path = direct_path.gsub(/:[^\/]+/, '').split('/').reject { |p| p.empty? }.join('/')

        fn :reset_view_path do
          presenter.path = File.join(view_path, 'show') if @presenter
        end

        get :list, '/'
        get :new,  '/new'
        get :show, "/#{resource_id}", before: [:reset_view_path]

        post :create, '/'

        get :edit, "/#{resource_id}/edit"
        patch :update, "/#{resource_id}"
        put :replace, "/#{resource_id}"
        delete :remove, "/#{resource_id}"

        group :collection
        namespace :member, resource_id
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pakyow-core-0.9.1 pakyow-core/lib/core/route_template_defaults.rb
pakyow-core-0.9.0 pakyow-core/lib/core/route_template_defaults.rb