Class: Switchboard::Commands::PubSub::Unsubscribe

Inherits:
Switchboard::Command show all
Defined in:
lib/switchboard/commands/pubsub/unsubscribe.rb

Class Method Summary collapse

Methods inherited from Switchboard::Command

description, help, options, to_command, to_command_name

Class Method Details

.run!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/switchboard/commands/pubsub/unsubscribe.rb', line 7

def self.run!
  switchboard = Switchboard::Client.new do
    # this executes in the main loop, so it doesn't really matter that this runs in a different thread
    defer :unsubscribed do
      unsubscribe_from(settings["pubsub.node"])
    end

    # define here or as hydrant.subscriptions_received
    def unsubscribed(successful)
      puts "Unsubscribe was successful." if successful
    end
  end

  if defined?(OAuth) && OPTIONS["oauth"]
    switchboard.plug!(OAuthPubSubJack)
  else
    switchboard.plug!(PubSubJack)
  end
  switchboard.run!
end