class Etwin::Link::LinkAction

Metadata about a link/unlink action

Attributes

time[R]
user[R]

Public Class Methods

deserialize(raw) click to toggle source
# File lib/etwin/link/link_action.rb, line 85
def deserialize(raw)
  time = Time.iso8601(raw['time'])
  user = User::ShortUser.deserialize(raw['user'])
  new(time, user)
end
from_json(json_str) click to toggle source
# File lib/etwin/link/link_action.rb, line 80
def from_json(json_str)
  deserialize JSON.parse(json_str)
end
new(time, user) click to toggle source
# File lib/etwin/link/link_action.rb, line 20
def initialize(time, user)
  @time = T.let(time, Time)
  @user = T.let(user, User::ShortUser)
  freeze
end

Public Instance Methods

==(other) click to toggle source
# File lib/etwin/link/link_action.rb, line 27
def ==(other)
  case other
  when LinkAction
    @time == other.time && @user == other.user
  else
    false
  end
end
as_json() click to toggle source
# File lib/etwin/link/link_action.rb, line 48
def as_json
  {
    'time' => @time,
    'user' => @user.as_json
  }
end
hash() click to toggle source
# File lib/etwin/link/link_action.rb, line 37
def hash
  [@time, @user].hash
end
inspect() click to toggle source
# File lib/etwin/link/link_action.rb, line 56
def inspect
  PP.singleline_pp(self, String.new)
end
pretty_print(pp) click to toggle source
# File lib/etwin/link/link_action.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 'time='
      pp.pp @time
      pp.text ','
      pp.breakable ''
      pp.text 'user='
      pp.pp @user
    end
    pp.breakable ''
  end
end
to_json(opts = nil) click to toggle source
# File lib/etwin/link/link_action.rb, line 43
def to_json(opts = nil)
  JSON.generate(as_json, opts)
end