Class: Tweet::Notifier

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

Overview

Plugin-based notification mechanism. When a Note is activated, it will call the Notifier#show method for each subclass of Notifier, which can be overridden to provide whatever functionality is required.

Example of a plugin:

class MyPlugin < Tweet::Notifier
     def show(e)
         puts "--"
         puts "alert!! there's a message for you: #{e}"
         puts "--"
    end
end

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.registered_notifiersObject (readonly)

Returns the value of attribute registered_notifiers.



421
422
423
# File 'lib/tweet.rb', line 421

def registered_notifiers
  @registered_notifiers
end

Class Method Details

.inherited(sub) ⇒ Object



423
424
425
426
427
428
429
# File 'lib/tweet.rb', line 423

def Notifier.inherited(sub)
  Notifier.registered_notifiers << sub
  begin
    Syslog.info("registered plugin: #{sub}")
  rescue
  end
end

Instance Method Details

#show(note) ⇒ Object

Override this method in a subclass (child) as a callback hook to provide a notification plugin.



433
434
435
# File 'lib/tweet.rb', line 433

def show(note)
  puts "[tweet!] #{note}"
end