Sha256: b660ea926ed4bdc10a17463eb0daad0f21133c14995b28b51ca961d66cd9bef3
Contents?: true
Size: 728 Bytes
Versions: 1
Compression:
Stored size: 728 Bytes
Contents
require 'singleton' module Waffle class Event include Singleton class << self # Syntactic sugar ^_^ def occured(*args) self.instance.occured(*args) end end def transport @transport ||= Waffle::Base.new eval("Waffle::Transports::#{Waffle::Config.transport.capitalize}").new end def encoder @encoder ||= eval("Waffle::Encoders::#{Waffle::Config.encoder.capitalize}") end def occured(event_name = 'event', event_data = nil) unless event_data.is_a? Hash event_data = {'body' => event_data.to_s} end event_data.merge!({'occured_at' => Time.now}) transport.publish event_name, encoder.encode(event_data) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
waffle-0.2.1 | lib/waffle/event.rb |