Module: Himari::Storages::Base

Included in:
Filesystem, Memory
Defined in:
lib/himari/storages/base.rb

Defined Under Namespace

Classes: Conflict

Instance Method Summary collapse

Instance Method Details

#delete_authorization(authz) ⇒ Object



19
20
21
# File 'lib/himari/storages/base.rb', line 19

def delete_authorization(authz)
  delete_authorization_by_code(authz.code)
end

#delete_authorization_by_code(code) ⇒ Object



23
24
25
# File 'lib/himari/storages/base.rb', line 23

def delete_authorization_by_code(code)
  delete('authz', code)
end

#delete_session(session) ⇒ Object



54
55
56
# File 'lib/himari/storages/base.rb', line 54

def delete_session(session)
  delete_session_by_handle(session.handle)
end

#delete_session_by_handle(handle) ⇒ Object



58
59
60
# File 'lib/himari/storages/base.rb', line 58

def delete_session_by_handle(handle)
  delete('session', handle)
end

#delete_token(token) ⇒ Object



37
38
39
# File 'lib/himari/storages/base.rb', line 37

def delete_token(token)
  delete_authorization_by_token(token.handle)
end

#delete_token_by_handle(handle) ⇒ Object



41
42
43
# File 'lib/himari/storages/base.rb', line 41

def delete_token_by_handle(handle)
  delete('token', handle)
end

#find_authorization(code) ⇒ Object



10
11
12
13
# File 'lib/himari/storages/base.rb', line 10

def find_authorization(code)
  content = read('authz', code)
  content && AuthorizationCode.new(**content)
end

#find_session(handle) ⇒ Object



45
46
47
48
# File 'lib/himari/storages/base.rb', line 45

def find_session(handle)
  content = read('session', handle)
  content && SessionData.new(**content)
end

#find_token(handle) ⇒ Object



27
28
29
30
31
# File 'lib/himari/storages/base.rb', line 27

def find_token(handle)
  content = read('token', handle)
  content[:handle] = content.delete(:handle) if content.key?(:handler) # compat
  content && AccessToken.new(**content)
end

#put_authorization(authz, overwrite: false) ⇒ Object



15
16
17
# File 'lib/himari/storages/base.rb', line 15

def put_authorization(authz, overwrite: false)
  write('authz', authz.code, authz.as_json, overwrite: overwrite)
end

#put_session(session, overwrite: false) ⇒ Object



50
51
52
# File 'lib/himari/storages/base.rb', line 50

def put_session(session, overwrite: false)
  write('session', session.handle, session.as_json, overwrite: overwrite)
end

#put_token(token, overwrite: false) ⇒ Object



33
34
35
# File 'lib/himari/storages/base.rb', line 33

def put_token(token, overwrite: false)
  write('token', token.handle, token.as_json, overwrite: overwrite)
end