Class: Devise::JWT::MappingInspector
- Inherits:
-
Object
- Object
- Devise::JWT::MappingInspector
- Defined in:
- lib/devise/jwt/mapping_inspector.rb
Overview
Inspect and extract information from a Devise mapping
Instance Attribute Summary collapse
-
#mapping ⇒ Object
readonly
Returns the value of attribute mapping.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #formats ⇒ Object
-
#initialize(scope) ⇒ MappingInspector
constructor
A new instance of MappingInspector.
- #jwt? ⇒ Boolean
-
#methods(name) ⇒ Object
:reek:ControlParameter.
- #model ⇒ Object
-
#path(name) ⇒ Object
:reek:FeatureEnvy.
- #registration? ⇒ Boolean
- #session? ⇒ Boolean
Constructor Details
#initialize(scope) ⇒ MappingInspector
Returns a new instance of MappingInspector.
9 10 11 12 |
# File 'lib/devise/jwt/mapping_inspector.rb', line 9 def initialize(scope) @scope = scope @mapping = Devise.mappings[scope] end |
Instance Attribute Details
#mapping ⇒ Object (readonly)
Returns the value of attribute mapping.
7 8 9 |
# File 'lib/devise/jwt/mapping_inspector.rb', line 7 def mapping @mapping end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
7 8 9 |
# File 'lib/devise/jwt/mapping_inspector.rb', line 7 def scope @scope end |
Instance Method Details
#formats ⇒ Object
48 49 50 |
# File 'lib/devise/jwt/mapping_inspector.rb', line 48 def formats JWT.config.request_formats[scope] || default_formats end |
#jwt? ⇒ Boolean
14 15 16 |
# File 'lib/devise/jwt/mapping_inspector.rb', line 14 def jwt? mapping.modules.member?(:jwt_authenticatable) end |
#methods(name) ⇒ Object
:reek:ControlParameter
39 40 41 42 43 44 45 46 |
# File 'lib/devise/jwt/mapping_inspector.rb', line 39 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 ⇒ Object
26 27 28 |
# File 'lib/devise/jwt/mapping_inspector.rb', line 26 def model mapping.to end |
#path(name) ⇒ Object
:reek:FeatureEnvy
31 32 33 34 35 36 |
# File 'lib/devise/jwt/mapping_inspector.rb', line 31 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? ⇒ Boolean
22 23 24 |
# File 'lib/devise/jwt/mapping_inspector.rb', line 22 def registration? routes?(:registration) end |
#session? ⇒ Boolean
18 19 20 |
# File 'lib/devise/jwt/mapping_inspector.rb', line 18 def session? routes?(:session) end |