Class: ValidationRage::ValidationRageNotifier

Inherits:
BaseNotifier
  • Object
show all
Defined in:
lib/validation_rage/validation_rage_notifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseNotifier

#data_present?, #subscribe!

Constructor Details

#initialize(args) ⇒ ValidationRageNotifier

Returns a new instance of ValidationRageNotifier.



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

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

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



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

def api_key
  @api_key
end

#hostObject

Returns the value of attribute host.



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

def host
  @host
end

#portObject

Returns the value of attribute port.



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

def port
  @port
end

#socketObject

Returns the value of attribute socket.



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

def socket
  @socket
end

Instance Method Details

#call(event_name, payload) ⇒ Object



13
14
15
16
# File 'lib/validation_rage/validation_rage_notifier.rb', line 13

def call(event_name, payload)
  data = {:api_key => self.api_key, :payload => payload}
  self.socket.send(data.to_json, 0, self.host, self.port)
end