Module: Putter::Watcher
- Extended by:
- MethodCreator
- Defined in:
- lib/putter/watcher.rb
Class Method Summary collapse
- .class_proxy(klass) ⇒ Object
- .label_for(klass) ⇒ Object
- .methods_for(klass) ⇒ Object
- .registry ⇒ Object
- .watch(obj, options = {}) ⇒ Object
Methods included from MethodCreator
Class Method Details
.class_proxy(klass) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/putter/watcher.rb', line 29 def self.class_proxy(klass) proxy = MethodProxy.new Putter::Watcher.methods_for(klass).each do |method| data = ProxyMethodData.new(label: Putter::Watcher.label_for(klass), method: method) add_putter_method_to_proxy(proxy, data) end proxy end |
.label_for(klass) ⇒ Object
21 22 23 |
# File 'lib/putter/watcher.rb', line 21 def self.label_for(klass) @registry[klass].label end |
.methods_for(klass) ⇒ Object
25 26 27 |
# File 'lib/putter/watcher.rb', line 25 def self.methods_for(klass) @registry[klass].proxy_methods end |
.registry ⇒ Object
17 18 19 |
# File 'lib/putter/watcher.rb', line 17 def self.registry @registry end |
.watch(obj, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/putter/watcher.rb', line 7 def self.watch(obj, ={}) data = WatcherData.new(, obj) @registry[obj.singleton_class] = data class << obj prepend InstanceFollower prepend Putter::Watcher.class_proxy(self) end end |