Class: Notify

Inherits:
Object
  • Object
show all
Defined in:
lib/notifyhub.rb

Overview

Notify object including disable/enable possibility.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&action) ⇒ Notify

Instantiation.

Parameters:

  • Notification action.



339
340
341
342
# File 'lib/notifyhub.rb', line 339

def initialize( &action )
    @action = action
    @enable = true
end

Instance Attribute Details

#enable(value) ⇒ Object (readonly)

Enable/disable Notify.

Parameters:

  • Enable with true and disable with false.



333
334
335
# File 'lib/notifyhub.rb', line 333

def enable
  @enable
end

Instance Method Details

#notify(*args) ⇒ Object

Perform notification action if enabled.

Parameters:

  • Data provided to action.



348
349
350
351
352
# File 'lib/notifyhub.rb', line 348

def notify( *args )
    if @enable
        @action.yield( *args )
    end
end