class TicketAbstractorClient::Base::Comment

Attributes

author[R]
body[R]
communications_stack[R]
data_hash[R]
external_created_at[R]

Public Class Methods

fetch(*opts) click to toggle source
# File lib/ticket_abstractor_client/base/comment.rb, line 6
def self.fetch(*opts)
  method_not_implemented __method__
end
new(opts) click to toggle source
# File lib/ticket_abstractor_client/base/comment.rb, line 10
def initialize(opts)
  opts = opts.with_indifferent_access
  @author = opts[:author]
  @body = opts.fetch(:body, nil) || raise(Errors::CommentArgumentError, 'Body is not given')
  @external_created_at = opts[:external_created_at]
  @data_hash = opts[:data_hash]
  @communications_stack = opts[:communications_stack] || []
  set_data_hash! if @data_hash.blank?
end

Protected Class Methods

method_not_implemented(method_name) click to toggle source
# File lib/ticket_abstractor_client/base/comment.rb, line 39
def self.method_not_implemented(method_name)
  raise Errors::NotImplementedError, "#{self}##{method_name} is not implemented"
end

Public Instance Methods

set_data_hash!() click to toggle source
# File lib/ticket_abstractor_client/base/comment.rb, line 20
def set_data_hash!
  content = "#{@external_created_at}:#{@author}:#{@body}"
  @data_hash = Digest::SHA512.hexdigest(content)
end
sync!() click to toggle source
# File lib/ticket_abstractor_client/base/comment.rb, line 25
def sync!
  self.class.method_not_implemented __method__
end
to_hash() click to toggle source
# File lib/ticket_abstractor_client/base/comment.rb, line 29
def to_hash
  { author: @author, body: @body, external_created_at: @external_created_at, data_hash: @data_hash }
end
to_json() click to toggle source
# File lib/ticket_abstractor_client/base/comment.rb, line 33
def to_json
  self.to_hash.to_json
end