Class: Darko::Watcher
- Inherits:
-
Object
- Object
- Darko::Watcher
- Defined in:
- lib/darko/watcher.rb
Instance Attribute Summary collapse
-
#delegator ⇒ Object
Returns the value of attribute delegator.
Instance Method Summary collapse
-
#disable! ⇒ Object
Disabling the Darko::Watcher will reset the object attribute to the original - removing the delegator.
-
#enable! ⇒ Object
Enabling the Darko::Watcher replaces the object with a Darko::Delegator to spy on mutations.
-
#initialize(object, attribute = nil, log_to_file = false) ⇒ Watcher
constructor
A new instance of Watcher.
Constructor Details
#initialize(object, attribute = nil, log_to_file = false) ⇒ Watcher
Returns a new instance of Watcher.
4 5 6 7 8 |
# File 'lib/darko/watcher.rb', line 4 def initialize object, attribute=nil, log_to_file=false @object = object @attribute = attribute @delegator = Darko::Delegator.new(attribute_target, log_to_file) end |
Instance Attribute Details
#delegator ⇒ Object
Returns the value of attribute delegator.
3 4 5 |
# File 'lib/darko/watcher.rb', line 3 def delegator @delegator end |
Instance Method Details
#disable! ⇒ Object
Disabling the Darko::Watcher will reset the object attribute to the original - removing the delegator
16 17 18 |
# File 'lib/darko/watcher.rb', line 16 def disable! swap_out_delegator end |
#enable! ⇒ Object
Enabling the Darko::Watcher replaces the object with a Darko::Delegator to spy on mutations
11 12 13 |
# File 'lib/darko/watcher.rb', line 11 def enable! swap_in_delegator end |