Sha256: d793f75b6ea17913428a8084797c1659da063a4a68f31c7188a7e03dcdc8148d

Contents?: true

Size: 1.99 KB

Versions: 10

Compression:

Stored size: 1.99 KB

Contents

require 'action_pack'

# :nodoc: namespace
module Authpwn

# :nodoc: namespace
module Routes

# :nodoc: mixed into ActionPack's route mapper.
module MapperMixin
  # Draws the routes for a session controller.
  #
  # The options hash accepts the following keys.
  #   :controller:: the name of the controller; defaults to "session" for
  #                 SessionController
  #   :paths:: the prefix of the route paths; defaults to the controller name
  #   :method_names:: the root of name used in the path methods; defaults to
  #                   "session", which will generate names like session_path,
  #                   new_session_path, and token_session_path
  def authpwn_session(options = {})
    controller = options[:controller] || 'session'
    paths = options[:paths] || controller
    methods = options[:method_names] || 'session'
    
    get "/#{paths}/token/:code", :controller => controller, :action => 'token',
                                 :as => :"token_#{methods}"
    
    get "/#{paths}", :controller => controller, :action => 'show',
                     :as => :"#{methods}"
    get "/#{paths}/new", :controller => controller, :action => 'new',
                         :as => :"new_#{methods}"
    post "/#{paths}", :controller => controller, :action => 'create'
    delete "/#{paths}", :controller => controller, :action => 'destroy'
    
    get "/#{paths}/change_password", :controller => controller,
                                    :action => 'password_change',
                                    :as => "change_password_#{methods}"
    post "/#{paths}/change_password", :controller => controller,
                                     :action => 'change_password'
    post "/#{paths}/reset_password", :controller => controller,
                                     :action => 'reset_password', 
                                     :as => "reset_password_#{methods}"
  end
end

ActionDispatch::Routing::Mapper.send :include, MapperMixin

end  # namespace Authpwn::Routes

end  # namespace Authpwn

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
authpwn_rails-0.12.0 lib/authpwn_rails/routes.rb
authpwn_rails-0.11.1 lib/authpwn_rails/routes.rb
authpwn_rails-0.11.0 lib/authpwn_rails/routes.rb
authpwn_rails-0.10.12 lib/authpwn_rails/routes.rb
authpwn_rails-0.10.11 lib/authpwn_rails/routes.rb
authpwn_rails-0.10.10 lib/authpwn_rails/routes.rb
authpwn_rails-0.10.9 lib/authpwn_rails/routes.rb
authpwn_rails-0.10.8 lib/authpwn_rails/routes.rb
authpwn_rails-0.10.7 lib/authpwn_rails/routes.rb
authpwn_rails-0.10.6 lib/authpwn_rails/routes.rb