Check Rails.version instead of ENV

Like that we can have code that works on multiple Rails versions, and we
dont need to mix a new method on Kernel.
Also, this makes easier to have multiple versions.
For instance, before master was 4.2, which is not the case anymore, so
on the code we should check versions and not Environment variables
This commit is contained in:
Arthur Neves
2015-04-24 16:22:24 -04:00
parent b2fd69a675
commit 439d0d2e37
5 changed files with 12 additions and 14 deletions

View File

@ -72,7 +72,7 @@ class SqlBuilder
#AS reloads this on tests
remove_const :FTYPE_MAP if defined? FTYPE_MAP
if rails_master?
if Rails.version >= "4.2.0"
FTYPE_MAP = {
23 => ActiveRecord::Type::Integer.new,
1114 => ActiveRecord::Type::DateTime.new,
@ -102,7 +102,7 @@ class SqlBuilder
setters.each_with_index do |mapper, index|
translated = row[index]
if mapper[1] && !translated.nil?
if rails_master?
if Rails.version >= "4.2.0"
translated = mapper[1].type_cast_from_database(translated)
else
translated = ActiveRecord::ConnectionAdapters::Column.send mapper[1], translated