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
-
#initialize(scope) ⇒ MappingInspector
constructor
A new instance of MappingInspector.
- #jwt? ⇒ Boolean
-
#method(name) ⇒ Object
:reek:ControlParameter.
- #model ⇒ Object
- #path(name) ⇒ Object
- #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
#jwt? ⇒ Boolean
14 15 16 |
# File 'lib/devise/jwt/mapping_inspector.rb', line 14 def jwt? mapping.modules.member?(:jwt_authenticatable) end |
#method(name) ⇒ Object
:reek:ControlParameter
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/devise/jwt/mapping_inspector.rb', line 36 def method(name) case name when :sign_in 'POST' when :sign_out sign_out_via.to_s.upcase when :registration 'POST' end end |
#model ⇒ Object
26 27 28 |
# File 'lib/devise/jwt/mapping_inspector.rb', line 26 def model mapping.to end |
#path(name) ⇒ Object
30 31 32 33 |
# File 'lib/devise/jwt/mapping_inspector.rb', line 30 def path(name) prefix, scope, request = path_parts(name) [prefix, scope, request].compact.join('/').prepend('/') 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 |