Add backwards compatibility define_singleton_method for Ruby 1.8.

This commit is contained in:
Patrick Mahoney committed 2011-12-12 20:51:06 -06:00
1 parent 2de2bc908b
commit 4f775ac5ca
3 files changed
+36

No files matched your search

+19
View File
@@ -1,6 +1,25 @@
require 'ffi'
if VERSION =~ /^1.8/
require 'process_shared/define_singleton_method'
module ProcessShared
module PSem
extend DefineSingletonMethod
end
module RT
extend DefineSingletonMethod
end
module LibC
extend DefineSingletonMethod
end
end
end
require 'process_shared/semaphore'
require 'process_shared/bounded_semaphore'
require 'process_shared/mutex'
require 'process_shared/shared_memory'
@@ -0,0 +1,14 @@
module ProcessShared
module DefineSingletonMethod
# This method was added in Ruby 1.9.x. Include this module for
# backwards compatibility.
#
# This isn't exactly compatible with the method in 1.9 which can
# take a Proc, Method, or a block. This only accepts a block.
def define_singleton_method(sym, &block)
eigenclass = class << self; self; end
eigenclass.send(:define_method, sym, &block)
end
end
end