Sha256: 1cc86c6c5f27015586b6d29df40db1de4fa74bbac22255eb43962303f17445f3

Contents?: true

Size: 653 Bytes

Versions: 1

Compression:

Stored size: 653 Bytes

Contents

require 'miu/resources/network'
require 'msgpack'

module Miu
  module Messages
    class Base
      attr_accessor :network, :type, :content

      def initialize(options = {})
        @network = options[:network] || Resources::Network.new(options[:network] || {})
        @type = options[:type]
        @type = [@type, *Array(options[:sub_type])].compact.join('.')
        @content = options[:content]
        yield self if block_given?
      end

      def to_hash
        {:network => @network.to_hash, :type => @type, :content => @content.to_hash}
      end

      def to_msgpack(*args)
        to_hash.to_msgpack(*args)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
miu-0.1.0 lib/miu/messages/base.rb