File: proc.rb

package info (click to toggle)
ruby-packable 1.3.14-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 204 kB
  • sloc: ruby: 609; makefile: 4
file content (16 lines) | stat: -rw-r--r-- 412 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module Packable
  module Extensions #:nodoc:
    module Proc
      # A bit of wizardry to return an +UnboundMethod+ which can be bound to any object
      def unbind
        Object.send(:define_method, :__temp_bound_method, &self)
        Object.instance_method(:__temp_bound_method)
      end

      # Shortcut for <tt>unbind.bind(to)</tt>
      def bind(to)
        unbind.bind(to)
      end
    end
  end
end