Class: Slnky::Service::Subscriptions

Inherits:
Object
  • Object
show all
Defined in:
lib/slnky/service/subscriptions.rb

Instance Method Summary collapse

Constructor Details

#initializeSubscriptions

Returns a new instance of Subscriptions.



4
5
6
# File 'lib/slnky/service/subscriptions.rb', line 4

def initialize
  @subs = []
end

Instance Method Details

#add(name, method) ⇒ Object



8
9
10
# File 'lib/slnky/service/subscriptions.rb', line 8

def add(name, method)
  @subs << {name: name, method: method}
end

#eachObject



12
13
14
15
16
# File 'lib/slnky/service/subscriptions.rb', line 12

def each
  @subs.each do |sub|
    yield sub[:name], sub[:method]
  end
end

#for(name) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/slnky/service/subscriptions.rb', line 18

def for(name)
  @subs.each do |sub|
    if sub[:name] == name || File.fnmatch(sub[:name], name)
      yield sub[:name], sub[:method] if block_given?
    end
  end
end