Module: Vayacondios::Notifications

Included in:
Vayacondios
Defined in:
lib/vayacondios/client/notifier.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/vayacondios/client/notifier.rb', line 103

def self.included klass
  if klass.ancestors.include? Gorillib::Model
    klass.class_eval do
      field :notifier, Vayacondios::NotifierFactory, default: Vayacondios.default_notifier, :doc => "Notifier used to notify out of band data"
      
      def receive_notifier params
        params.merge!(log: try(:log)) if params[:type] == 'log'
        @notifier = Vayacondios::NotifierFactory.receive(params)
      end
    end
  else
    klass.class_attribute :notifier
    klass.notifier = Vayacondios.default_notifier try(:log)
  end
end

Instance Method Details

#notify(topic, cargo = {}) ⇒ Object



99
100
101
# File 'lib/vayacondios/client/notifier.rb', line 99

def notify(topic, cargo = {})
  notifier.notify(topic, cargo)
end