Class: ValidationRage::BaseNotifier

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

Defined Under Namespace

Classes: NotImplementedError

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ BaseNotifier

Returns a new instance of BaseNotifier.



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

def initialize(args={})
end

Instance Method Details

#call(event_name, payload) ⇒ Object



7
8
9
# File 'lib/validation_rage/base_notifier.rb', line 7

def call(event_name, payload)
  raise NotImplementedError.new("your notifer must implement a call(event_name, payload) method")
end

#data_present?(payload) ⇒ Boolean

Returns:

  • (Boolean)


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

def data_present?(payload)
  payload.values.first && !payload.values.first.empty?
end

#subscribe!Object



10
11
12
# File 'lib/validation_rage/base_notifier.rb', line 10

def subscribe!
  ActiveSupport::Notifications.subscribe(/validation_rage:.*/, self)
end