Class: Tobacco::Callback
- Inherits:
-
Object
- Object
- Tobacco::Callback
- Defined in:
- lib/tobacco/callback.rb
Instance Attribute Summary collapse
-
#writer ⇒ Object
Returns the value of attribute writer.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(writer = nil) ⇒ Callback
constructor
A new instance of Callback.
-
#notify(name, data) ⇒ Object
Public: Notify the writer class based on callback name passing along data which is either content or an error object.
Constructor Details
#initialize(writer = nil) ⇒ Callback
Returns a new instance of Callback.
10 11 12 |
# File 'lib/tobacco/callback.rb', line 10 def initialize(writer = nil) self.writer = writer end |
Instance Attribute Details
#writer ⇒ Object
Returns the value of attribute writer.
3 4 5 |
# File 'lib/tobacco/callback.rb', line 3 def writer @writer end |
Class Method Details
.instance(writer = nil) ⇒ Object
5 6 7 |
# File 'lib/tobacco/callback.rb', line 5 def self.instance(writer = nil) @instance ||= new(writer) end |
Instance Method Details
#notify(name, data) ⇒ Object
Public: Notify the writer class based on callback name
passing along data which is either content or
an error object
name - symbol - the callback name
data - text or object
return - data
24 25 26 27 28 29 30 |
# File 'lib/tobacco/callback.rb', line 24 def notify(name, data) if writer.respond_to? name writer.send(name, data) else data end end |