class Putter::Follower

Attributes

object[R]
proxy[R]

Public Class Methods

new(obj, options={}) click to toggle source
# File lib/putter/follower.rb, line 7
def initialize(obj, options={})
  @object = obj
  @proxy = MethodProxy.new
  begin
    @object.singleton_class.send(:prepend, proxy)
  rescue ::NoMethodError
    ::Kernel.raise ::Putter::BasicObjectError
  end
  @data = FollowerData.new(@object, @proxy, options)
end

Public Instance Methods

add_method(method) click to toggle source
# File lib/putter/follower.rb, line 30
def add_method(method)
  proxy_method_data = ProxyMethodData.new(label: @data.label, method: method)

  add_putter_method_to_proxy(@proxy, proxy_method_data)
end
method_missing(method, *args, &blk) click to toggle source
# File lib/putter/follower.rb, line 18
def method_missing(method, *args, &blk)
  if @data.add_method?(method)
    add_method(method)
  end

  if blk
    @object.send(method, *args, &blk)
  else
    @object.send(method, *args)
  end
end