Sha256: 5cd741a4c47e8f7aca641bb8c3a28ed450190498761674b5a9b35b1425049eb9

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

module ActionDispatch::Routing
  

  class Mapper
    #Includes the ninsho_on method for routes. This method is responsible
    # for creating all the routes needed.
    #
    # == Example
    #
    # Assuming you have an authentications model on your application,
    # your routes should look like:
    #
    #   ninsho_on :authentications
    #   
    #   This method will generate something like:
    #
    #   Session routes
    #   new_authentication_session_path GET /sign_in { controller: 'ninsho/sessions', action: 'new' }
    #       authentication_session_path POST /authentication/:provider/callback { controller: 'ninsho/sessions', action: 'create' }
    #   destroy_authentication_session_path DELETE /sign_out { controller: 'ninsho/sessions', action: 'destroy' }
    #

     def ninsho_on(resources_name)
       drawer = Ninsho::RoutesDrawer.new resources_name
       Ninsho.resource_class = drawer.to
       Ninsho.resource_name = drawer.resource
       ninsho_session(drawer.singular_name)
     end

     protected

     def ninsho_session(name) #:nodoc:
       resource :session, :only => [], :controller => 'ninsho/sessions', :path => "" do
       get :new, :path => 'sign_in', as: "new_#{name}"
       match :create, path: "auth/:provider/callback", as: "#{name}"
       delete :destroy, path: 'sign_out', as: "destroy_#{name}"
     end
     end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ninsho-0.0.1 lib/ninsho/rails/routes.rb