class Smith::ACL::Default
Default
message. This takes any object that can be marshalled. If no content is passed in on the constructor then an the message is assigned an empty Hash. method_missing
is declared and will update the hash.
Public Class Methods
new(message={})
click to toggle source
# File lib/smith/messaging/acl/default.rb, line 10 def initialize(message={}) @message = message end
Public Instance Methods
inspect()
click to toggle source
# File lib/smith/messaging/acl/default.rb, line 30 def inspect "<#{self.class.to_s}> -> #{(self.respond_to?(:to_hash)) ? self.to_hash : self.to_s}" end
method_missing(method, args)
click to toggle source
# File lib/smith/messaging/acl/default.rb, line 38 def method_missing(method, args) match = /(.*?)=$/.match(method.to_s) if match && match[1] index = match[1].to_sym @message[index] = args else raise NoMethodError, "undefined method `#{method}' for #{self}", caller end end
parse_from_string(message)
click to toggle source
# File lib/smith/messaging/acl/default.rb, line 18 def parse_from_string(message) Marshal.load(message) end
serialize_to_string()
click to toggle source
# File lib/smith/messaging/acl/default.rb, line 14 def serialize_to_string Marshal.dump(@message) end
to_hash()
click to toggle source
# File lib/smith/messaging/acl/default.rb, line 26 def to_hash @message && @message.to_hash end
to_json()
click to toggle source
# File lib/smith/messaging/acl/default.rb, line 34 def to_json MultiJson.dump(@message) end
to_s()
click to toggle source
# File lib/smith/messaging/acl/default.rb, line 22 def to_s @message.to_s end