Class: Flashover
- Inherits:
-
Object
- Object
- Flashover
- Defined in:
- lib/flashover.rb
Defined Under Namespace
Classes: Crypto, MaryPoppins
Constant Summary collapse
- VERSION =
"0.0.6"- MESSAGE_TYPES =
[ :sms, :phone, :email, :page_view, :generic, :backup, :notification ].freeze
Instance Attribute Summary collapse
-
#environment ⇒ Object
writeonly
Sets the attribute environment.
-
#redis ⇒ Object
Returns the value of attribute redis.
Instance Method Summary collapse
-
#event(type, payload) ⇒ Object
‘type’ dictates the message pipeline payload is shoved down can be: -> :sms -> :phone_call -> :email -> :page_view -> :generic.
-
#initialize(redis, passphrase, salt) ⇒ Flashover
constructor
A new instance of Flashover.
- #listen(listening_channel = nil, &blk) ⇒ Object
Constructor Details
Instance Attribute Details
#environment=(value) ⇒ Object
Sets the attribute environment
19 20 21 |
# File 'lib/flashover.rb', line 19 def environment=(value) @environment = value end |
#redis ⇒ Object
Returns the value of attribute redis.
19 20 21 |
# File 'lib/flashover.rb', line 19 def redis @redis end |
Instance Method Details
#event(type, payload) ⇒ Object
‘type’ dictates the message pipeline payload is shoved down can be: -> :sms -> :phone_call -> :email -> :page_view -> :generic
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/flashover.rb', line 33 def event(type, payload) begin @redis.publish(convert_symbol_to_channel(type), build_payload(payload)) true rescue Errno::ETIMEDOUT => ex Bugsnag.notify(ex) logger "Flashover TIMEOUT @ #{Time.now.ctime}" false rescue => ex Bugsnag.notify(ex) logger "BANG @ Flashover#event => #{ex.class} -> '#{ex.}'" false end end |
#listen(listening_channel = nil, &blk) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/flashover.rb', line 48 def listen(listening_channel = nil, &blk) raise MaryPoppins.new("block must have two args") unless blk.arity == 2 @redis.subscribe() do |on| on. do |channel, | channel = convert_channel_to_symbol(channel) if listening_channel yield(channel, ()) if listening_channel == channel else yield(channel, ()) end end end end |