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

- (Notify) initialize(&action)

Instantiation.

Parameters:

  • action (Proc)

    Notification action.



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

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

Instance Attribute Details

- (Object) enable(value) (readonly)

Enable/disable Notify.

Parameters:

  • value (Boolean)

    Enable with true and disable with false.



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

def enable
  @enable
end

Instance Method Details

- (Object) notify(*args)

Perform notification action if enabled.

Parameters:

  • args (Array<Object>)

    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