Class: FaaStRuby::EventChannel

Inherits:
Object
  • Object
show all
Defined in:
lib/faastruby/server/event_channel.rb

Constant Summary collapse

@@channels =
{}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel) ⇒ EventChannel

Returns a new instance of EventChannel.



8
9
10
11
# File 'lib/faastruby/server/event_channel.rb', line 8

def initialize(channel)
  @name = channel
  @@channels[channel] ||= []
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/faastruby/server/event_channel.rb', line 7

def name
  @name
end

Class Method Details

.channelsObject



4
5
6
# File 'lib/faastruby/server/event_channel.rb', line 4

def self.channels
  @@channels
end

Instance Method Details

#subscribe(function_path) ⇒ Object



12
13
14
# File 'lib/faastruby/server/event_channel.rb', line 12

def subscribe(function_path)
  @@channels[@name] << function_path
end

#subscribersObject



15
16
17
# File 'lib/faastruby/server/event_channel.rb', line 15

def subscribers
  @@channels[@name] || []
end