Class: Switchboard::Commands::PubSub::Affiliations

Inherits:
Switchboard::Command show all
Defined in:
lib/switchboard/commands/pubsub/affiliations.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
27
28
29
30
# File 'lib/switchboard/commands/pubsub/affiliations.rb', line 7

def self.run!
  switchboard = Switchboard::Client.new do
    defer :affiliations_received do
      pubsub.get_affiliations(OPTIONS["pubsub.node"])
    end

    def affiliations_received(affiliations)
      if affiliations
        affiliations.each do |node, affiliation|
          puts [node, affiliation] * " => "
        end
      else
        puts "No affiliations."
      end
    end
  end

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