Class: ValidationRage::UdpNotifier

Inherits:
BaseNotifier show all
Defined in:
lib/validation_rage/udp_notifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseNotifier

#data_present?, #subscribe!

Constructor Details

#initialize(args) ⇒ UdpNotifier

Returns a new instance of UdpNotifier.



6
7
8
9
10
# File 'lib/validation_rage/udp_notifier.rb', line 6

def initialize(args)
  self.socket = UDPSocket.new
  self.host = args[:host]
  self.port = args[:port]
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



5
6
7
# File 'lib/validation_rage/udp_notifier.rb', line 5

def host
  @host
end

#portObject

Returns the value of attribute port.



5
6
7
# File 'lib/validation_rage/udp_notifier.rb', line 5

def port
  @port
end

#socketObject

Returns the value of attribute socket.



5
6
7
# File 'lib/validation_rage/udp_notifier.rb', line 5

def socket
  @socket
end

Instance Method Details

#call(event_name, payload) ⇒ Object



12
13
14
# File 'lib/validation_rage/udp_notifier.rb', line 12

def call(event_name, payload)
  self.socket.send(payload.to_json, 0, self.host, self.port)
end