Module: Auth::OmniAuth::Path
- Defined in:
- lib/auth/omniauth/path.rb
Class Method Summary collapse
-
.common_callback_path(provider) ⇒ Object
the path for the callback is the same for all models.
- .create_or_index_path(cls) ⇒ Object
- .edit_path(cls) ⇒ Object
-
.model_to_path(cls) ⇒ Object
given something like :Shopping::Product will return something like shopping/products.
- .new_path(cls) ⇒ Object
-
.omniauth_failure_absolute_path ⇒ Object
the absolute path that is returned by the omniauth url helper devise takes care of prepending the resource and the mount prefix.
-
.omniauth_failure_route_path(resource_or_scope) ⇒ Object
this is the path that is used in the routes.rb file, to build the actual route.
-
.omniauth_prefix_path ⇒ Object
the omniauth prefix = mount_path/omniauth.
-
.omniauth_request_path(resource, provider) ⇒ Object
the the path for the request_phase of the omniauth call.
-
.path_to_model(path) ⇒ Object
given something like : shopping/product will return something like: Shopping::Product.
-
.pathify(cls_name_as_string) ⇒ Object
FOR BUILDING THE PATHS FOR ALL CLASSES.
-
.resource_path(resource) ⇒ Object
the path prefix for all the devise modules.
- .resource_pluralized(resource) ⇒ Object
- .show_or_update_or_delete_path(cls) ⇒ Object
Class Method Details
.common_callback_path(provider) ⇒ Object
the path for the callback is the same for all models.
72 73 74 |
# 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) ⇒ Object
28 29 30 31 32 |
# 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) ⇒ Object
34 35 36 |
# 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) ⇒ Object
given something like :Shopping::Product will return something like shopping/products
53 54 55 56 57 |
# 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) ⇒ Object
17 18 19 |
# 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 ⇒ Object
the absolute path that is returned by the omniauth url helper devise takes care of prepending the resource and the mount prefix.
87 88 89 |
# File 'lib/auth/omniauth/path.rb', line 87 def self.omniauth_failure_absolute_path "omniauth/failed" end |
.omniauth_failure_route_path(resource_or_scope) ⇒ Object
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.
94 95 96 97 |
# 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 ⇒ Object
the omniauth prefix = mount_path/omniauth
67 68 69 |
# File 'lib/auth/omniauth/path.rb', line 67 def self.omniauth_prefix_path "#{Auth.configuration.mount_path}/omniauth" end |
.omniauth_request_path(resource, provider) ⇒ Object
the the path for the request_phase of the omniauth call.
60 61 62 63 64 |
# 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) ⇒ Object
given something like : shopping/product will return something like: Shopping::Product
47 48 49 |
# 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) ⇒ Object
13 14 15 |
# 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) ⇒ Object
the path prefix for all the devise modules.
81 82 83 |
# File 'lib/auth/omniauth/path.rb', line 81 def self.resource_path(resource) "#{Auth.configuration.mount_path}/#{resource_pluralized resource}" end |
.resource_pluralized(resource) ⇒ Object
76 77 78 |
# 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) ⇒ Object
21 22 23 24 25 |
# 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 |