Class: Etwin::Auth::GuestAuthContext

Inherits:
Object
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/etwin/auth/guest_auth_context.rb

Overview

Guest authentication context

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope) ⇒ GuestAuthContext

Returns a new instance of GuestAuthContext.



17
18
19
20
# File 'lib/etwin/auth/guest_auth_context.rb', line 17

def initialize(scope)
  @scope = T.let(scope, AuthScope)
  freeze
end

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



14
15
16
# File 'lib/etwin/auth/guest_auth_context.rb', line 14

def scope
  @scope
end

Class Method Details

.deserialize(raw) ⇒ Object



64
65
66
67
# File 'lib/etwin/auth/guest_auth_context.rb', line 64

def deserialize(raw)
  scope = AuthScope.deserialize(raw['scope'])
  new(scope)
end

.from_json(json_str) ⇒ Object



59
60
61
# File 'lib/etwin/auth/guest_auth_context.rb', line 59

def from_json(json_str)
  deserialize JSON.parse(json_str)
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/etwin/auth/guest_auth_context.rb', line 23

def ==(other)
  case other
  when GuestAuthContext
    @scope == other.scope
  else
    false
  end
end

#as_jsonObject



44
45
46
47
48
# File 'lib/etwin/auth/guest_auth_context.rb', line 44

def as_json
  {
    'scope' => @scope.serialize
  }
end

#hashObject



33
34
35
# File 'lib/etwin/auth/guest_auth_context.rb', line 33

def hash
  [@scope].hash
end

#inspectObject



51
52
53
# File 'lib/etwin/auth/guest_auth_context.rb', line 51

def inspect
  "GuestAuthContext(scope=#{@scope.inspect})"
end

#to_json(opts = nil) ⇒ Object



39
40
41
# File 'lib/etwin/auth/guest_auth_context.rb', line 39

def to_json(opts = nil)
  JSON.generate(as_json, opts)
end