Sha256: d382263bd5fb0e4d0c138471330dc4e0427b2545278c24aa9121b99b19935169
Contents?: true
Size: 763 Bytes
Versions: 2
Compression:
Stored size: 763 Bytes
Contents
require 'miu/messages' require 'msgpack' require 'securerandom' module Miu module Messages class Base attr_accessor :id, :time attr_accessor :network, :type, :content def initialize(options = {}) @id = options[:id] || SecureRandom.uuid @time = options[:time] || Time.now.to_i @network = Miu::Utility.adapt(Resources::Network, options[:network] || {}) @type = options[:type] @content = options[:content] yield self if block_given? end def to_h { :network => @network.to_h, :type => @type, :content => @content ? @content.to_h : {} } end def to_msgpack(*args) to_h.to_msgpack(*args) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
miu-0.2.2 | lib/miu/messages/base.rb |
miu-0.2.1 | lib/miu/messages/base.rb |