Permalink
Browse files

backports the gem so it can be used with rails 2.3

in rails 2.3 the HashWithIndifferentAccess wasn't modularized so we
check if there this class without module and than load this and if it's
in the module it will loaded from the ActiveSupport module
  • Loading branch information...
Jens Fahnenbruck
Jens Fahnenbruck committed May 18, 2011
1 parent 32818c6 commit a0e49b4733b2ff7cb4ef059f100574fc42028356
Showing with 3 additions and 3 deletions.
  1. +1 −1 Gemfile
  2. +2 −2 lib/sugarcrm/attributes/attribute_validations.rb
View
@@ -1,6 +1,6 @@
source "http://rubygems.org"
-gem "activesupport", ">= 3.0.0", :require => "active_support"
+gem "activesupport", ">= 2.3.10", :require => "active_support"
gem "i18n"
gem "json"
@@ -1,7 +1,7 @@
module SugarCRM; module AttributeValidations
# Checks to see if we have all the neccessary attributes
def valid?
- @errors = ActiveSupport::HashWithIndifferentAccess.new
+ @errors = (defined?(HashWithIndifferentAccess) ? HashWithIndifferentAccess : ActiveSupport::HashWithIndifferentAccess).new
self.class._module.required_fields.each do |attribute|
valid_attribute?(attribute)
@@ -59,4 +59,4 @@ def add_error(attribute, message)
@errors[attribute] = @errors[attribute] << message unless @errors[attribute].include? message
@errors
end
-end; end
+end; end

0 comments on commit a0e49b4

Please sign in to comment.