Class: Pushr::Daemon::App

Inherits:
Object
  • Object
show all
Defined in:
lib/pushr/daemon/app.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ App

Returns a new instance of App.



26
27
28
29
30
# File 'lib/pushr/daemon/app.rb', line 26

def initialize(config)
  @config = config
  @handlers = []
  @provider = nil
end

Class Attribute Details

.appsObject (readonly)

Returns the value of attribute apps.



7
8
9
# File 'lib/pushr/daemon/app.rb', line 7

def apps
  @apps
end

Class Method Details

.loadObject



9
10
11
# File 'lib/pushr/daemon/app.rb', line 9

def load
  @apps = Pushr::Configuration.all.keep_if { |c| c.enabled == true }.map { |c| App.new(c) }
end

.startObject



17
18
19
# File 'lib/pushr/daemon/app.rb', line 17

def start
  @apps.map(&:start)
end

.stopObject



21
22
23
# File 'lib/pushr/daemon/app.rb', line 21

def stop
  @apps.map(&:stop)
end

.total_connectionsObject



13
14
15
# File 'lib/pushr/daemon/app.rb', line 13

def total_connections
  @apps.map(&:connections).inject(0, :+)
end

Instance Method Details

#connectionsObject



32
33
34
# File 'lib/pushr/daemon/app.rb', line 32

def connections
  @config.connections
end

#startObject



36
37
38
39
# File 'lib/pushr/daemon/app.rb', line 36

def start
  @provider = load_provider(@config.name, @config)
  @provider.start
end

#stopObject



41
42
43
# File 'lib/pushr/daemon/app.rb', line 41

def stop
  @provider.stop
end