Sha256: 3b2b405368db0499e6cca9ecbeb2d37e5b63a55a97688c383fbd4a5291bbed78

Contents?: true

Size: 656 Bytes

Versions: 3

Compression:

Stored size: 656 Bytes

Contents

# frozen_string_literal: true

module Hahamut
  module Message
    # Abstract Message
    class Base
      class << self
        def match?(_message)
          false
        end
      end

      include Support::Attributes

      attr_reader :sender_id

      # TODO: Improve sender / recipient setup
      def initialize(attributes, sender_id = nil)
        assign_attributes(attributes)
        @sender_id = sender_id
      end

      def type
        raise NotImplementedError
      end

      def as_json(_obj = nil)
        @attributes.dup.merge(type: type)
      end

      def to_json(_obj = nil)
        as_json.to_json
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hahamut-0.1.2 lib/hahamut/message/base.rb
hahamut-0.1.1 lib/hahamut/message/base.rb
hahamut-0.1.0 lib/hahamut/message/base.rb