Class: Devise::JWT::MappingInspector

Inherits:
Object
  • Object
show all
Defined in:
lib/devise/jwt/mapping_inspector.rb

Overview

Inspect and extract information from a Devise mapping

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#mappingObject (readonly)

Returns the value of attribute mapping.



7
8
9
# File 'lib/devise/jwt/mapping_inspector.rb', line 7

def mapping
  @mapping
end

#scopeObject (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

Returns:

  • (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

#modelObject



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

Returns:

  • (Boolean)


22
23
24
# File 'lib/devise/jwt/mapping_inspector.rb', line 22

def registration?
  routes?(:registration)
end

#session?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/devise/jwt/mapping_inspector.rb', line 18

def session?
  routes?(:session)
end