class CycloneLariat::Abstract::Message

Attributes

publisher[RW]
type[RW]
uuid[RW]

Public Instance Methods

==(other) click to toggle source
# File lib/cyclone_lariat/abstract/message.rb, line 53
def ==(other)
  kind == other.kind &&
    uuid == other.uuid &&
    publisher == other.publisher &&
    type == other.type &&
    client_error&.message == other.client_error&.message &&
    client_error&.details == other.client_error&.details &&
    version == other.version &&
    sent_at.to_i == other.sent_at.to_i &&
    received_at.to_i == other.received_at.to_i &&
    processed_at.to_i == other.processed_at.to_i
end
client_error_details=(details) click to toggle source
# File lib/cyclone_lariat/abstract/message.rb, line 46
def client_error_details=(details)
  return unless details

  @client_error ||= Errors::ClientError.new
  @client_error.details = details
end
client_error_message=(txt) click to toggle source
# File lib/cyclone_lariat/abstract/message.rb, line 39
def client_error_message=(txt)
  return unless txt

  @client_error ||= Errors::ClientError.new
  @client_error.message = txt
end
kind() click to toggle source
# File lib/cyclone_lariat/abstract/message.rb, line 15
def kind
  raise LunaPark::Errors::AbstractMethod
end
processed?() click to toggle source
# File lib/cyclone_lariat/abstract/message.rb, line 35
def processed?
  !@processed_at.nil?
end
processed_at=(value) click to toggle source
# File lib/cyclone_lariat/abstract/message.rb, line 31
def processed_at=(value)
  @processed_at = wrap_time(value)
end
received_at=(value) click to toggle source
# File lib/cyclone_lariat/abstract/message.rb, line 27
def received_at=(value)
  @received_at = wrap_time(value)
end
sent_at=(value) click to toggle source
# File lib/cyclone_lariat/abstract/message.rb, line 23
def sent_at=(value)
  @sent_at = wrap_time(value)
end
to_json(*args) click to toggle source
# File lib/cyclone_lariat/abstract/message.rb, line 66
def to_json(*args)
  hash = serialize
  hash[:type] = [kind, hash[:type]].join '_'
  hash.to_json(*args)
end
version=(value) click to toggle source
# File lib/cyclone_lariat/abstract/message.rb, line 19
def version=(value)
  @version = Integer(value)
end

Private Instance Methods

wrap_time(value) click to toggle source
# File lib/cyclone_lariat/abstract/message.rb, line 74
def wrap_time(value)
  case value
  when String   then Time.parse(value)
  when Time     then value
  when NilClass then nil
  else raise ArgumentError, "Unknown type `#{value.class}`"
  end
end