Skip to content

Commit

Permalink
Gem version changes shouldn't be happening on the fly, so cache these…
Browse files Browse the repository at this point in the history
… values to avoid lots of unnecessary string comparisons
  • Loading branch information
Jon Calvert committed Apr 14, 2015
1 parent 4f6054f commit 27ef485
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/goldiloader/compatibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ module Goldiloader
module Compatibility

def self.mass_assignment_security_enabled?
::ActiveRecord::VERSION::MAJOR < 4 || defined?(::ActiveRecord::MassAssignmentSecurity)
@mass_assignment_security_enabled ||= (::ActiveRecord::VERSION::MAJOR < 4 || defined?(::ActiveRecord::MassAssignmentSecurity))
end

def self.association_finder_sql_enabled?
::Gem::Version.new(::ActiveRecord::VERSION::STRING) < ::Gem::Version.new('4.1')
@association_finder_sql ||= (::Gem::Version.new(::ActiveRecord::VERSION::STRING) < ::Gem::Version.new('4.1'))
end

def self.unscope_query_method_enabled?
::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new('4.1')
@unscope_query_method ||= ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new('4.1')
end
end
end

0 comments on commit 27ef485

Please sign in to comment.