Add backwards compatibility define_singleton_method for Ruby 1.8.

This commit is contained in:
Patrick Mahoney 2011-12-12 20:51:06 -06:00
parent 2de2bc908b
commit 4f775ac5ca
3 changed files with 36 additions and 0 deletions

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'

View File

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

View File

@ -1,8 +1,11 @@
require 'rubygems' if VERSION =~ /^1.8/
gem 'minitest'
require 'minitest/spec'
require 'minitest/autorun'
require 'minitest/matchers'
require 'process_shared'
class RangeMatcher
def initialize(operator, limit)
@operator = operator.to_sym