Class: Etwin::User::UserDisplayNameVersion

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

Overview

Eternal-Twin user display name with metadata

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ UserDisplayNameVersion

Returns a new instance of UserDisplayNameVersion.



17
18
19
20
# File 'lib/etwin/user/user_display_name_version.rb', line 17

def initialize(value)
  @value = T.let(value, UserDisplayName)
  freeze
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



14
15
16
# File 'lib/etwin/user/user_display_name_version.rb', line 14

def value
  @value
end

Class Method Details

.deserialize(raw) ⇒ Object



76
77
78
79
# File 'lib/etwin/user/user_display_name_version.rb', line 76

def deserialize(raw)
  value = UserDisplayName.new(raw['value'])
  new(value)
end

.from_json(json_str) ⇒ Object



71
72
73
# File 'lib/etwin/user/user_display_name_version.rb', line 71

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/user/user_display_name_version.rb', line 23

def ==(other)
  case other
  when UserDisplayNameVersion
    @value == other.value
  else
    false
  end
end

#as_jsonObject



44
45
46
47
48
# File 'lib/etwin/user/user_display_name_version.rb', line 44

def as_json
  {
    'value' => @value.as_json
  }
end

#hashObject



33
34
35
# File 'lib/etwin/user/user_display_name_version.rb', line 33

def hash
  [@value].hash
end

#inspectObject



51
52
53
# File 'lib/etwin/user/user_display_name_version.rb', line 51

def inspect
  PP.singleline_pp(self, String.new)
end

#pretty_print(pp) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'lib/etwin/user/user_display_name_version.rb', line 56

def pretty_print(pp)
  pp.group(0, "#{self.class.name}(", ')') do
    pp.nest 1 do
      pp.breakable ''
      pp.text 'value='
      pp.pp @value
    end
    pp.breakable ''
  end
end

#to_json(opts = nil) ⇒ Object



39
40
41
# File 'lib/etwin/user/user_display_name_version.rb', line 39

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