class Axon::AxonMsg
Constants
- KEY_ERROR
Public Class Methods
new(data = {}, error = nil)
click to toggle source
# File lib/axon-nats/msg.rb, line 10 def initialize(data = {}, error = nil) raise "data must be a hash" unless data.is_a? Hash @data = data @data[KEY_ERROR] = error unless error.nil? end
parse(msg_s)
click to toggle source
# File lib/axon-nats/msg.rb, line 6 def self.parse(msg_s) msg_o = JSON.parse(msg_s) AxonMsg.new(msg_o, msg_o[KEY_ERROR]) end
Public Instance Methods
[](key)
click to toggle source
# File lib/axon-nats/msg.rb, line 15 def [](key) @data[key.to_s] end
[]=(key, value)
click to toggle source
# File lib/axon-nats/msg.rb, line 18 def []=(key, value) @data[key.to_s] = value end
error?()
click to toggle source
# File lib/axon-nats/msg.rb, line 21 def error? !@data[KEY_ERROR].nil? end
method_missing(method, *args)
click to toggle source
# File lib/axon-nats/msg.rb, line 30 def method_missing(method, *args) @data.send(method, *args) if @data.respond_to? method end
to_s()
click to toggle source
# File lib/axon-nats/msg.rb, line 24 def to_s JSON.generate(@data) end
to_str()
click to toggle source
# File lib/axon-nats/msg.rb, line 27 def to_str to_s end