Class: Device::NotificationCallback
- Inherits:
-
Object
- Object
- Device::NotificationCallback
- Defined in:
- lib/device/notification_callback.rb
Constant Summary collapse
- CallbackResult =
DaFunk::Struct.klass(:before_execute, :result, :after_execute)
Instance Attribute Summary collapse
-
#after ⇒ Object
readonly
Returns the value of attribute after.
-
#before ⇒ Object
readonly
Returns the value of attribute before.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#on ⇒ Object
readonly
Returns the value of attribute on.
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
- #call(event, moment = :on) ⇒ Object
-
#initialize(description, procs = {}) ⇒ NotificationCallback
constructor
A new instance of NotificationCallback.
- #schedule! ⇒ Object
Constructor Details
#initialize(description, procs = {}) ⇒ NotificationCallback
Returns a new instance of NotificationCallback.
8 9 10 11 12 13 14 15 |
# File 'lib/device/notification_callback.rb', line 8 def initialize(description, procs = {}) @description = description @on = procs[:on] @before = procs[:before] @after = procs[:after] @results = {:on => [], :before => [], :after => []} schedule! end |
Instance Attribute Details
#after ⇒ Object (readonly)
Returns the value of attribute after.
3 4 5 |
# File 'lib/device/notification_callback.rb', line 3 def after @after end |
#before ⇒ Object (readonly)
Returns the value of attribute before.
3 4 5 |
# File 'lib/device/notification_callback.rb', line 3 def before @before end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/device/notification_callback.rb', line 3 def description @description end |
#on ⇒ Object (readonly)
Returns the value of attribute on.
3 4 5 |
# File 'lib/device/notification_callback.rb', line 3 def on @on end |
#results ⇒ Object
Returns the value of attribute results.
4 5 6 |
# File 'lib/device/notification_callback.rb', line 4 def results @results end |
Instance Method Details
#call(event, moment = :on) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/device/notification_callback.rb', line 21 def call(event, moment = :on) if support?(moment) results[moment] << CallbackResult.call( Time.now, perform(event, moment), Time.now ) end end |
#schedule! ⇒ Object
17 18 19 |
# File 'lib/device/notification_callback.rb', line 17 def schedule! Notification.schedule(self) end |