class Etwin::Auth::UserAuthContext

User authentication context

Attributes

is_administrator[R]
scope[R]
user[R]

Public Class Methods

deserialize(raw) click to toggle source
# File lib/etwin/auth/user_auth_context.rb, line 74
def deserialize(raw)
  scope = AuthScope.deserialize(raw['scope'])
  user = Etwin::User::ShortUser.deserialize(raw['user'])
  is_administrator = raw['is_administrator']
  new(scope, user, is_administrator)
end
from_json(json_str) click to toggle source
# File lib/etwin/auth/user_auth_context.rb, line 69
def from_json(json_str)
  deserialize JSON.parse(json_str)
end
new(scope, user, is_administrator) click to toggle source
# File lib/etwin/auth/user_auth_context.rb, line 23
def initialize(scope, user, is_administrator)
  @scope = T.let(scope, AuthScope)
  @user = T.let(user, Etwin::User::ShortUser)
  @is_administrator = T.let(is_administrator, T::Boolean)
  freeze
end

Public Instance Methods

==(other) click to toggle source
# File lib/etwin/auth/user_auth_context.rb, line 31
def ==(other)
  case other
  when UserAuthContext
    @scope == other.scope && @user == other.user && @is_administrator == other.is_administrator
  else
    false
  end
end
as_json() click to toggle source
# File lib/etwin/auth/user_auth_context.rb, line 52
def as_json
  {
    'scope' => @scope.serialize,
    'user' => @user.as_json,
    'is_administrator' => @is_administrator
  }
end
hash() click to toggle source
# File lib/etwin/auth/user_auth_context.rb, line 41
def hash
  [@scope, @user, @is_administrator].hash
end
inspect() click to toggle source
# File lib/etwin/auth/user_auth_context.rb, line 61
def inspect
  "UserAuthContext(scope=#{@scope.inspect},user=#{@user.inspect},is_administrator=#{@is_administrator.inspect})"
end
to_json(opts = nil) click to toggle source
# File lib/etwin/auth/user_auth_context.rb, line 47
def to_json(opts = nil)
  JSON.generate(as_json, opts)
end