module Auth::OmniAuth::Path

Public Class Methods

common_callback_path(provider) click to toggle source

the path for the callback is the same for all models.

# File lib/auth/omniauth/path.rb, line 72
def self.common_callback_path(provider)
        "#{omniauth_prefix_path}/#{provider}/callback"
end
create_or_index_path(cls) click to toggle source
# File lib/auth/omniauth/path.rb, line 28
def self.create_or_index_path(cls)
        parts = cls.constantize.new.class.name.split("::")
        parts[-1] = parts[-1].pluralize
        parts.map{|c| c.underscore.downcase}.join("_") + "_path"
end
edit_path(cls) click to toggle source
# File lib/auth/omniauth/path.rb, line 34
def self.edit_path(cls)                              
        "edit_" + show_or_update_or_delete_path(cls)
end
model_to_path(cls) click to toggle source

given something like :Shopping::Product will return something like shopping/products

# File lib/auth/omniauth/path.rb, line 53
def self.model_to_path(cls)
        parts = cls.to_s.split("::").map{|c| c = c.to_s.downcase}
        parts[-1] = parts[-1].pluralize
        parts.join("/")
end
new_path(cls) click to toggle source
# File lib/auth/omniauth/path.rb, line 17
def self.new_path(cls)
        "new_" + cls.constantize.new.class.name.underscore.gsub(/\//,"_") + "_path"
end
omniauth_failure_absolute_path() click to toggle source

the absolute path that is returned by the omniauth url helper devise takes care of prepending the resource and the mount prefix.

# File lib/auth/omniauth/path.rb, line 87
def self.omniauth_failure_absolute_path
        "omniauth/failed"
end
omniauth_failure_route_path(resource_or_scope) click to toggle source

this is the path that is used in the routes.rb file, to build the actual route. keeps :res as a wildcard for the required resource.

# File lib/auth/omniauth/path.rb, line 94
def self.omniauth_failure_route_path(resource_or_scope)
        resource_or_scope = resource_or_scope.nil? ? ":res" : resource_pluralized(resource_or_scope.class.name)
        "#{Auth.configuration.mount_path}/#{resource_or_scope}/#{omniauth_failure_absolute_path}"
end
omniauth_prefix_path() click to toggle source

the omniauth prefix = mount_path/omniauth

# File lib/auth/omniauth/path.rb, line 67
def self.omniauth_prefix_path
        "#{Auth.configuration.mount_path}/omniauth"
end
omniauth_request_path(resource,provider) click to toggle source

the the path for the request_phase of the omniauth call.

# File lib/auth/omniauth/path.rb, line 60
def self.omniauth_request_path(resource,provider)
        resource_or_scope = resource.nil? ? ":res" : 
        resource_pluralized(resource)
        "#{omniauth_prefix_path}/#{resource_or_scope}/#{provider}"
end
path_to_model(path) click to toggle source

given something like : shopping/product will return something like: Shopping::Product

# File lib/auth/omniauth/path.rb, line 47
def self.path_to_model(path)
        path.split("/").map{|c| c = c.capitalize}.join("::").constantize
end
pathify(cls_name_as_string) click to toggle source

FOR BUILDING THE PATHS FOR ALL CLASSES.

given something like Auth::Shopping::CartItem , will return auth/shopping/cart_item @param cls_name_as_string : the name of the class , as a string. @retunrn the pathified version of the class name.

# File lib/auth/omniauth/path.rb, line 13
def self.pathify(cls_name_as_string)
        cls_name_as_string.split("::").map{|c| c = c.underscore}.join("/")
end
resource_path(resource) click to toggle source

the path prefix for all the devise modules.

# File lib/auth/omniauth/path.rb, line 81
def self.resource_path(resource)     
        "#{Auth.configuration.mount_path}/#{resource_pluralized resource}"
end
resource_pluralized(resource) click to toggle source
# File lib/auth/omniauth/path.rb, line 76
def self.resource_pluralized(resource)
        resource.to_s.pluralize.underscore.gsub('/', '_')
end
show_or_update_or_delete_path(cls) click to toggle source
# File lib/auth/omniauth/path.rb, line 21
def self.show_or_update_or_delete_path(cls)
        
        parts = cls.constantize.new.class.name.split("::")
        parts.map{|c| c.underscore.downcase}.join("_") + "_path"
end