Sha256: 641e0ce47b8f3dcbdea6cc4c2266d4fa6f3533bf47f3b98684f642d3b83a4b35

Contents?: true

Size: 817 Bytes

Versions: 5

Compression:

Stored size: 817 Bytes

Contents

module Putter
  module Watcher
    extend MethodCreator

    @registry = {}

    def self.watch(obj, options={})
      data = WatcherData.new(options, obj)
      @registry[obj.singleton_class] = data

      class << obj
        prepend InstanceFollower
        prepend Putter::Watcher.class_proxy(self)
      end
    end

    def self.registry
      @registry
    end

    def self.label_for(klass)
      @registry[klass].label
    end

    def self.methods_for(klass)
      @registry[klass].proxy_methods
    end

    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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
putter-0.7.0 lib/putter/watcher.rb
putter-0.6.1 lib/putter/watcher.rb
putter-0.6.0 lib/putter/watcher.rb
putter-0.5.1 lib/putter/watcher.rb
putter-0.5.0 lib/putter/watcher.rb