class Devise::JWT::MappingInspector
Inspect and extract information from a Devise
mapping
Attributes
mapping[R]
scope[R]
Public Class Methods
new(scope)
click to toggle source
# File lib/devise/jwt/mapping_inspector.rb, line 9 def initialize(scope) @scope = scope @mapping = Devise.mappings[scope] end
Public Instance Methods
formats()
click to toggle source
# File lib/devise/jwt/mapping_inspector.rb, line 46 def formats JWT.config.request_formats[scope] || default_formats end
jwt?()
click to toggle source
# File lib/devise/jwt/mapping_inspector.rb, line 14 def jwt? mapping.modules.member?(:jwt_authenticatable) end
methods(name)
click to toggle source
# File lib/devise/jwt/mapping_inspector.rb, line 37 def methods(name) method = case name when :sign_in then 'POST' when :sign_out then sign_out_via when :registration then 'POST' end Array(method) end
model()
click to toggle source
# File lib/devise/jwt/mapping_inspector.rb, line 26 def model mapping.to end
path(name)
click to toggle source
# File lib/devise/jwt/mapping_inspector.rb, line 30 def path(name) prefix, scope, request = path_parts(name) [prefix, scope, request].delete_if do |item| !item || item.empty? end.join('/').prepend('/').gsub('//', '/') end
registration?()
click to toggle source
# File lib/devise/jwt/mapping_inspector.rb, line 22 def registration? routes?(:registration) end
session?()
click to toggle source
# File lib/devise/jwt/mapping_inspector.rb, line 18 def session? routes?(:session) end
Private Instance Methods
default_formats()
click to toggle source
# File lib/devise/jwt/mapping_inspector.rb, line 69 def default_formats [nil] end
path_parts(name)
click to toggle source
# File lib/devise/jwt/mapping_inspector.rb, line 52 def path_parts(name) prefix = mapping.instance_variable_get(:@path_prefix) path = mapping.path path_name = mapping.path_names[name] [prefix, path, path_name] end
routes?(name)
click to toggle source
# File lib/devise/jwt/mapping_inspector.rb, line 59 def routes?(name) mapping.routes.member?(name) end
sign_out_via()
click to toggle source
# File lib/devise/jwt/mapping_inspector.rb, line 63 def sign_out_via Array(mapping.sign_out_via).map do |method| method.to_s.upcase end end