diff options
author | Iain Beeston <iain.beeston@gmail.com> | 2016-10-03 14:06:11 +0100 |
---|---|---|
committer | Iain Beeston <iain.beeston@gmail.com> | 2016-10-14 20:21:20 +0100 |
commit | 994ce87bbda7cc4b0059c951b06cdd15dc26cb97 (patch) | |
tree | 64da21f688868906bf1c6548606c4cab392de416 /activerecord/lib | |
parent | 159b774887cfb3d5c862b2b48d24d75b658e47af (diff) | |
download | rails-994ce87bbda7cc4b0059c951b06cdd15dc26cb97.tar.gz rails-994ce87bbda7cc4b0059c951b06cdd15dc26cb97.tar.bz2 rails-994ce87bbda7cc4b0059c951b06cdd15dc26cb97.zip |
Moved database-specific ActiveModel types into ActiveRecord
ie. DecimalWithoutScale, Text and UnsignedInteger
Diffstat (limited to 'activerecord/lib')
4 files changed, 36 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/type.rb b/activerecord/lib/active_record/type.rb index 84373dddf2..3333a1a620 100644 --- a/activerecord/lib/active_record/type.rb +++ b/activerecord/lib/active_record/type.rb @@ -7,7 +7,10 @@ require "active_record/type/internal/timezone" require "active_record/type/date" require "active_record/type/date_time" +require "active_record/type/decimal_without_scale" require "active_record/type/time" +require "active_record/type/text" +require "active_record/type/unsigned_integer" require "active_record/type/serialized" require "active_record/type/adapter_specific_registry" @@ -54,12 +57,9 @@ module ActiveRecord Binary = ActiveModel::Type::Binary Boolean = ActiveModel::Type::Boolean Decimal = ActiveModel::Type::Decimal - DecimalWithoutScale = ActiveModel::Type::DecimalWithoutScale Float = ActiveModel::Type::Float Integer = ActiveModel::Type::Integer String = ActiveModel::Type::String - Text = ActiveModel::Type::Text - UnsignedInteger = ActiveModel::Type::UnsignedInteger register(:big_integer, Type::BigInteger, override: false) register(:binary, Type::Binary, override: false) diff --git a/activerecord/lib/active_record/type/decimal_without_scale.rb b/activerecord/lib/active_record/type/decimal_without_scale.rb new file mode 100644 index 0000000000..7ce33e9cd3 --- /dev/null +++ b/activerecord/lib/active_record/type/decimal_without_scale.rb @@ -0,0 +1,9 @@ +module ActiveRecord + module Type + class DecimalWithoutScale < ActiveModel::Type::BigInteger # :nodoc: + def type + :decimal + end + end + end +end diff --git a/activerecord/lib/active_record/type/text.rb b/activerecord/lib/active_record/type/text.rb new file mode 100644 index 0000000000..cb1949700a --- /dev/null +++ b/activerecord/lib/active_record/type/text.rb @@ -0,0 +1,9 @@ +module ActiveRecord + module Type + class Text < ActiveModel::Type::String # :nodoc: + def type + :text + end + end + end +end diff --git a/activerecord/lib/active_record/type/unsigned_integer.rb b/activerecord/lib/active_record/type/unsigned_integer.rb new file mode 100644 index 0000000000..9ae0109f9f --- /dev/null +++ b/activerecord/lib/active_record/type/unsigned_integer.rb @@ -0,0 +1,15 @@ +module ActiveRecord + module Type + class UnsignedInteger < ActiveModel::Type::Integer # :nodoc: + private + + def max_value + super * 2 + end + + def min_value + 0 + end + end + end +end |