Class: NotifySet
- Inherits:
-
Object
- Object
- NotifySet
- Defined in:
- lib/notifyhub.rb
Overview
Notify object that includes disable/enable features.
Instance Attribute Summary (collapse)
-
- (Object) enable(value)
Enable/disable Notify set.
Instance Method Summary (collapse)
-
- (Object) [](idx)
Get Notify by index.
-
- (Object) action(&action)
(also: #register, #with)
Register Notify.
-
- (Object) each
Iterate over list of notifiers.
-
- (NotifySet) initialize(id = nil)
constructor
Instantiation.
-
- (Object) notify(*args)
Run all notifiers in Notify set.
-
- (Object) remove(notify = nil)
Remove all or one Notify.
Constructor Details
- (NotifySet) initialize(id = nil)
Instantiation.
238 239 240 241 242 |
# File 'lib/notifyhub.rb', line 238 def initialize( id = nil ) @id = id @enable = true @list = [] end |
Instance Attribute Details
- (Object) enable(value)
Enable/disable Notify set.
232 233 234 |
# File 'lib/notifyhub.rb', line 232 def enable @enable end |
Instance Method Details
- (Object) [](idx)
Get Notify by index.
298 299 300 |
# File 'lib/notifyhub.rb', line 298 def []( idx ) @list[ idx ] end |
- (Object) action(&action) Also known as: register, with
Register Notify.
256 257 258 259 260 |
# File 'lib/notifyhub.rb', line 256 def action( &action ) n = Notify.new( &action ) @list.push n n end |
- (Object) each
Iterate over list of notifiers.
290 291 292 293 294 |
# File 'lib/notifyhub.rb', line 290 def each @list.each do |n| yield n end end |
- (Object) notify(*args)
Run all notifiers in Notify set.
280 281 282 283 284 285 286 |
# File 'lib/notifyhub.rb', line 280 def notify( *args ) if @enable @list.each do |n| n.notify( *args ) end end end |
- (Object) remove(notify = nil)
Remove all or one Notify.
269 270 271 272 273 274 275 |
# File 'lib/notifyhub.rb', line 269 def remove( notify = nil ) if notify @list.delete( notify ) else @list = [] end end |