class ADM::Message
Attributes
compiled[R]
data[R]
hydra[W]
Public Class Methods
new(data={})
click to toggle source
# File lib/adm/message.rb, line 5 def initialize data={} @data = data end
Public Instance Methods
compile()
click to toggle source
# File lib/adm/message.rb, line 29 def compile @json ||= begin @compiled = true compiled_data = data.dup if compiled_data[:data] compiled_data[:data].each do |k,v| compiled_data[:data][k] = MultiJson.dump(compiled_data[:data][k]) end elsif compiled_data['data'] compiled_data['data'].each do |k,v| compiled_data['data'][k] = MultiJson.dump(compiled_data['data'][k]) end end MultiJson.dump(compiled_data) end end
hydra()
click to toggle source
# File lib/adm/message.rb, line 25 def hydra @hydra ||= Typhoeus::Hydra.hydra end
send_to(*tokens)
click to toggle source
# File lib/adm/message.rb, line 9 def send_to *tokens if tokens.first.is_a?(Array) tokens = tokens.first end notifications = tokens.collect do |token| note = ADM::Notification.new(token,self) note.queue(hydra) note end hydra.run notifications end