class Etwin::User::ShortUser
User
with minimum data to identify and display them
Attributes
display_name[R]
id[R]
Public Class Methods
deserialize(raw)
click to toggle source
# File lib/etwin/user/short_user.rb, line 85 def deserialize(raw) id = UserId.new(raw['id']) display_name = UserDisplayNameVersions.deserialize(raw['display_name']) new(id, display_name) end
from_json(json_str)
click to toggle source
# File lib/etwin/user/short_user.rb, line 80 def from_json(json_str) deserialize JSON.parse(json_str) end
new(id, display_name)
click to toggle source
# File lib/etwin/user/short_user.rb, line 20 def initialize(id, display_name) @id = T.let(id, UserId) @display_name = T.let(display_name, UserDisplayNameVersions) freeze end
Public Instance Methods
==(other)
click to toggle source
# File lib/etwin/user/short_user.rb, line 27 def ==(other) case other when ShortUser @id == other.id && @display_name == other.display_name else false end end
as_json()
click to toggle source
# File lib/etwin/user/short_user.rb, line 48 def as_json { 'id' => @id.as_json, 'display_name' => @display_name.as_json } end
hash()
click to toggle source
# File lib/etwin/user/short_user.rb, line 37 def hash [@id, @display_name].hash end
inspect()
click to toggle source
# File lib/etwin/user/short_user.rb, line 56 def inspect PP.singleline_pp(self, String.new) end
pretty_print(pp)
click to toggle source
# File lib/etwin/user/short_user.rb, line 61 def pretty_print(pp) # rubocop:disable Metrics/MethodLength pp.group(0, "#{self.class.name}(", ')') do pp.nest 1 do pp.breakable '' pp.text 'id=' pp.pp @id pp.text ',' pp.breakable '' pp.text 'display_name=' pp.pp @display_name end pp.breakable '' end end
to_json(opts = nil)
click to toggle source
# File lib/etwin/user/short_user.rb, line 43 def to_json(opts = nil) JSON.generate(as_json, opts) end