Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pathsny/294596 to your computer and use it in GitHub Desktop.
Save pathsny/294596 to your computer and use it in GitHub Desktop.
From bd48a4b5b39a8fe6ede3570eac3d97b47af1fb84 Mon Sep 17 00:00:00 2001
From: Vishnu Iyengar <pathsny@gmail.com>
Date: Thu, 4 Feb 2010 18:14:19 +0530
Subject: [PATCH] workaround with numeric validator to work with jruby
---
.../dm-validations/validators/numeric_validator.rb | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/dm-validations/lib/dm-validations/validators/numeric_validator.rb b/dm-validations/lib/dm-validations/validators/numeric_validator.rb
index 841a0bc..9b9729a 100644
--- a/dm-validations/lib/dm-validations/validators/numeric_validator.rb
+++ b/dm-validations/lib/dm-validations/validators/numeric_validator.rb
@@ -62,6 +62,10 @@ module DataMapper
def validate_with_comparison(value, cmp, expected, error_message_name, errors, negated = false)
return if expected.nil?
+ $~ = nil #bugfix for jruby. This is needed because the jruby compiler optimizes a bit too far with magic variables like $~.
+ # the value.send line sends $~. Inserting this line makes sure the jruby compiler does not optimise here.
+ # see http://jira.codehaus.org/browse/JRUBY-3765
+
comparison = value.send(cmp, expected)
return if negated ? !comparison : comparison
--
1.6.5.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment