Class: ForeignOffice::Busses::PusherBus

Inherits:
GenericBus
  • Object
show all
Defined in:
lib/foreign_office/busses/pusher_bus.rb

Class Method Summary collapse

Methods inherited from GenericBus

#publish

Class Method Details

.app_idObject



11
12
13
# File 'lib/foreign_office/busses/pusher_bus.rb', line 11

def self.app_id
  @app_id
end

.app_id=(app_id) ⇒ Object



7
8
9
# File 'lib/foreign_office/busses/pusher_bus.rb', line 7

def self.app_id=(app_id)
  @app_id = app_id
end

.config(config) ⇒ Object



2
3
4
5
# File 'lib/foreign_office/busses/pusher_bus.rb', line 2

def self.config(config)
  # Pusher now pulls config directly from the ENV
  Pusher.encrypted = true
end

.connectionObject



31
32
33
# File 'lib/foreign_office/busses/pusher_bus.rb', line 31

def self.connection
  @pusher ||= Pusher
end

.keyObject



19
20
21
# File 'lib/foreign_office/busses/pusher_bus.rb', line 19

def self.key
  @key
end

.key=(key) ⇒ Object



15
16
17
# File 'lib/foreign_office/busses/pusher_bus.rb', line 15

def self.key=(key)
  @key = key
end

.publish(message) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/foreign_office/busses/pusher_bus.rb', line 35

def self.publish(message)
  message.symbolize_keys!
  channel = sanitize_channel(message[:channel])
  self.connection.trigger(
    channel,
    'publish',
    message
  )
end

.sanitize_channel(channel) ⇒ Object



45
46
47
# File 'lib/foreign_office/busses/pusher_bus.rb', line 45

def self.sanitize_channel(channel)
  channel.gsub(/::/,'.')
end

.secretObject



27
28
29
# File 'lib/foreign_office/busses/pusher_bus.rb', line 27

def self.secret
  @secret
end

.secret=(secret) ⇒ Object



23
24
25
# File 'lib/foreign_office/busses/pusher_bus.rb', line 23

def self.secret=(secret)
  @secret = secret
end