Class: Slnky::Service::Subscriptions
- Inherits:
-
Object
- Object
- Slnky::Service::Subscriptions
- Defined in:
- lib/slnky/service/subscriptions.rb
Instance Method Summary collapse
- #add(name, method) ⇒ Object
- #each ⇒ Object
- #for(name) ⇒ Object
-
#initialize ⇒ Subscriptions
constructor
A new instance of Subscriptions.
Constructor Details
#initialize ⇒ Subscriptions
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 |
#each ⇒ Object
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 |