diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2016-12-08 13:45:47 -0500 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2016-12-08 13:45:47 -0500 |
commit | ef76f83f4cf0f27e84c0c5f4a3ff426d7ad84d9d (patch) | |
tree | 673c743609e2c3730706eae5ded47c40c6acf4f0 | |
parent | 6e948f480118bceb66b72a53874b800fbda05327 (diff) | |
parent | 994ce87bbda7cc4b0059c951b06cdd15dc26cb97 (diff) | |
download | rails-ef76f83f4cf0f27e84c0c5f4a3ff426d7ad84d9d.tar.gz rails-ef76f83f4cf0f27e84c0c5f4a3ff426d7ad84d9d.tar.bz2 rails-ef76f83f4cf0f27e84c0c5f4a3ff426d7ad84d9d.zip |
Merge pull request #26696 from iainbeeston/only-ruby-types-in-activemodel
Moved database-specific ActiveModel types into ActiveRecord
-rw-r--r-- | activemodel/CHANGELOG.md | 4 | ||||
-rw-r--r-- | activemodel/lib/active_model/type.rb | 4 | ||||
-rw-r--r-- | activemodel/lib/active_model/type/decimal_without_scale.rb | 11 | ||||
-rw-r--r-- | activemodel/lib/active_model/type/text.rb | 11 | ||||
-rw-r--r-- | activerecord/CHANGELOG.md | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/type.rb | 7 | ||||
-rw-r--r-- | activerecord/lib/active_record/type/decimal_without_scale.rb | 9 | ||||
-rw-r--r-- | activerecord/lib/active_record/type/text.rb | 9 | ||||
-rw-r--r-- | activerecord/lib/active_record/type/unsigned_integer.rb (renamed from activemodel/lib/active_model/type/unsigned_integer.rb) | 4 | ||||
-rw-r--r-- | activerecord/test/cases/type/unsigned_integer_test.rb (renamed from activemodel/test/cases/type/unsigned_integer_test.rb) | 5 |
10 files changed, 33 insertions, 35 deletions
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index 9c53e2ecec..853a1e7d9d 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -1,3 +1,7 @@ +* Moved DecimalWithoutScale, Text, and UnsignedInteger from Active Model to Active Record + + *Iain Beeston* + * Allow indifferent access in `ActiveModel::Errors`. `#include?`, `#has_key?`, `#key?`, `#delete` and `#full_messages_for`. diff --git a/activemodel/lib/active_model/type.rb b/activemodel/lib/active_model/type.rb index 0d3349e236..b8e6d2376b 100644 --- a/activemodel/lib/active_model/type.rb +++ b/activemodel/lib/active_model/type.rb @@ -7,14 +7,11 @@ require "active_model/type/boolean" require "active_model/type/date" require "active_model/type/date_time" require "active_model/type/decimal" -require "active_model/type/decimal_without_scale" require "active_model/type/float" require "active_model/type/immutable_string" require "active_model/type/integer" require "active_model/type/string" -require "active_model/type/text" require "active_model/type/time" -require "active_model/type/unsigned_integer" require "active_model/type/registry" @@ -53,7 +50,6 @@ module ActiveModel register(:immutable_string, Type::ImmutableString) register(:integer, Type::Integer) register(:string, Type::String) - register(:text, Type::Text) register(:time, Type::Time) end end diff --git a/activemodel/lib/active_model/type/decimal_without_scale.rb b/activemodel/lib/active_model/type/decimal_without_scale.rb deleted file mode 100644 index 985e1038ed..0000000000 --- a/activemodel/lib/active_model/type/decimal_without_scale.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "active_model/type/big_integer" - -module ActiveModel - module Type - class DecimalWithoutScale < BigInteger # :nodoc: - def type - :decimal - end - end - end -end diff --git a/activemodel/lib/active_model/type/text.rb b/activemodel/lib/active_model/type/text.rb deleted file mode 100644 index 7c0d647706..0000000000 --- a/activemodel/lib/active_model/type/text.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "active_model/type/string" - -module ActiveModel - module Type - class Text < String # :nodoc: - def type - :text - end - end - end -end diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index d7c2d80f33..8e2c039575 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,7 @@ +* Moved DecimalWithoutScale, Text, and UnsignedInteger from Active Model to Active Record + + *Iain Beeston* + * Fix `write_attribute` method to check whether an attribute is aliased or not, and use the aliased attribute name if needed. diff --git a/activerecord/lib/active_record/type.rb b/activerecord/lib/active_record/type.rb index 0b48d2186a..fdf124283d 100644 --- a/activerecord/lib/active_record/type.rb +++ b/activerecord/lib/active_record/type.rb @@ -5,7 +5,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" @@ -53,13 +56,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 - Value = ActiveModel::Type::Value 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/activemodel/lib/active_model/type/unsigned_integer.rb b/activerecord/lib/active_record/type/unsigned_integer.rb index 288fa23efe..9ae0109f9f 100644 --- a/activemodel/lib/active_model/type/unsigned_integer.rb +++ b/activerecord/lib/active_record/type/unsigned_integer.rb @@ -1,6 +1,6 @@ -module ActiveModel +module ActiveRecord module Type - class UnsignedInteger < Integer # :nodoc: + class UnsignedInteger < ActiveModel::Type::Integer # :nodoc: private def max_value diff --git a/activemodel/test/cases/type/unsigned_integer_test.rb b/activerecord/test/cases/type/unsigned_integer_test.rb index 026cb08a06..1cd4dbc2c5 100644 --- a/activemodel/test/cases/type/unsigned_integer_test.rb +++ b/activerecord/test/cases/type/unsigned_integer_test.rb @@ -1,9 +1,8 @@ require "cases/helper" -require "active_model/type" -module ActiveModel +module ActiveRecord module Type - class UnsignedIntegerTest < ActiveModel::TestCase + class UnsignedIntegerTest < ActiveRecord::TestCase test "unsigned int max value is in range" do assert_equal(4294967295, UnsignedInteger.new.serialize(4294967295)) end |