Class: Plugin
- Inherits:
-
Object
- Object
- Plugin
- Defined in:
- lib/raphael/plugin.rb
Direct Known Subclasses
Command, DeletedTweet, Error, Event, FriendList, Init, Tweet
Class Attribute Summary collapse
-
.plugins ⇒ Object
(also: all)
readonly
Returns the value of attribute plugins.
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#proc ⇒ Object
readonly
Returns the value of attribute proc.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts = {}, &blk) ⇒ Plugin
constructor
A new instance of Plugin.
Constructor Details
#initialize(opts = {}, &blk) ⇒ Plugin
Returns a new instance of Plugin.
5 6 7 8 |
# File 'lib/raphael/plugin.rb', line 5 def initialize opts={}, &blk @proc = blk @opts = opts end |
Class Attribute Details
.plugins ⇒ Object (readonly) Also known as: all
Returns the value of attribute plugins.
11 12 13 |
# File 'lib/raphael/plugin.rb', line 11 def plugins @plugins end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
4 5 6 |
# File 'lib/raphael/plugin.rb', line 4 def opts @opts end |
#proc ⇒ Object (readonly)
Returns the value of attribute proc.
4 5 6 |
# File 'lib/raphael/plugin.rb', line 4 def proc @proc end |
Class Method Details
.callback(*args) ⇒ Object
19 20 21 22 23 |
# File 'lib/raphael/plugin.rb', line 19 def callback *args Array(@plugins).each do |plugin| plugin.proc.call *args end end |
.hook(opts = {}, &blk) ⇒ Object
14 15 16 17 |
# File 'lib/raphael/plugin.rb', line 14 def hook opts={}, &blk @plugins ||= [] @plugins << self.new(opts, &blk) end |