class Proc

Copyright © 2009 Paolo Capriotti <p.capriotti@gmail.com>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Public Instance Methods

bind(object) click to toggle source

Bind this Proc to an object.

# File lib/rui/factory.rb, line 12
def bind(object)
  block, time = self, Time.now
  (class << object; self end).class_eval do
    method_name = "__bind_#{time.to_i}_#{time.usec}"
    define_method(method_name, &block)
    method = instance_method(method_name)
    remove_method(method_name)
    method
  end.bind(object)
end
generic_call(args) click to toggle source
# File lib/rui/observer_utils.rb, line 142
def generic_call(args)
  case arity
  when 0
    call
  when 1
    call(args)
  else
    call(*args)
  end
end