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

#formatsObject



50
51
52
# File 'lib/devise/jwt/mapping_inspector.rb', line 50

def formats
  JWT.config.request_formats[scope] || default_formats
end

#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



39
40
41
42
43
44
45
46
47
48
# File 'lib/devise/jwt/mapping_inspector.rb', line 39

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

: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

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