diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-02-07 17:36:22 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-02-07 17:36:22 -0700 |
commit | 1492e83e49f74b1d874585000bad5368d9f09218 (patch) | |
tree | d51bf5354264b3b8843101ee331451f14f231505 /activerecord | |
parent | 16629c099ca30895c90661d5cbce40e218f0984e (diff) | |
download | rails-1492e83e49f74b1d874585000bad5368d9f09218.tar.gz rails-1492e83e49f74b1d874585000bad5368d9f09218.tar.bz2 rails-1492e83e49f74b1d874585000bad5368d9f09218.zip |
rm `Type#number?`
This predicate is only used in `query_attribute`, and is relatively easy
to remove without adding a bunch of is a checks.
Diffstat (limited to 'activerecord')
17 files changed, 1 insertions, 29 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/query.rb b/activerecord/lib/active_record/attribute_methods/query.rb index 83b858aae7..553122a5fc 100644 --- a/activerecord/lib/active_record/attribute_methods/query.rb +++ b/activerecord/lib/active_record/attribute_methods/query.rb @@ -15,7 +15,6 @@ module ActiveRecord when false, nil then false else column = self.class.columns_hash[attr_name] - type = self.class.type_for_attribute(attr_name) if column.nil? if Numeric === value || value !~ /[^0-9]/ !value.to_i.zero? @@ -23,7 +22,7 @@ module ActiveRecord return false if ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.include?(value) !value.blank? end - elsif type.number? + elsif value.respond_to?(:zero?) !value.zero? else !value.blank? diff --git a/activerecord/lib/active_record/type/helpers/numeric.rb b/activerecord/lib/active_record/type/helpers/numeric.rb index 86888eef75..b0d4f03117 100644 --- a/activerecord/lib/active_record/type/helpers/numeric.rb +++ b/activerecord/lib/active_record/type/helpers/numeric.rb @@ -2,10 +2,6 @@ module ActiveRecord module Type module Helpers module Numeric # :nodoc: - def number? - true - end - def type_cast(value) value = case value when true then 1 diff --git a/activerecord/lib/active_record/type/value.rb b/activerecord/lib/active_record/type/value.rb index 7f384bee68..7338920f3b 100644 --- a/activerecord/lib/active_record/type/value.rb +++ b/activerecord/lib/active_record/type/value.rb @@ -52,10 +52,6 @@ module ActiveRecord # These predicates are not documented, as I need to look further into # their use, and see if they can be removed entirely. - def number? # :nodoc: - false - end - def binary? # :nodoc: false end diff --git a/activerecord/test/cases/adapters/postgresql/array_test.rb b/activerecord/test/cases/adapters/postgresql/array_test.rb index 35b792b1c2..19ebef4981 100644 --- a/activerecord/test/cases/adapters/postgresql/array_test.rb +++ b/activerecord/test/cases/adapters/postgresql/array_test.rb @@ -36,14 +36,12 @@ class PostgresqlArrayTest < ActiveRecord::TestCase assert_equal :string, @column.type assert_equal "character varying", @column.sql_type assert @column.array? - assert_not @type.number? assert_not @type.binary? ratings_column = PgArray.columns_hash['ratings'] assert_equal :integer, ratings_column.type type = PgArray.type_for_attribute("ratings") assert ratings_column.array? - assert_not type.number? end def test_default diff --git a/activerecord/test/cases/adapters/postgresql/bit_string_test.rb b/activerecord/test/cases/adapters/postgresql/bit_string_test.rb index 52fa46bd01..6c6b4dc22a 100644 --- a/activerecord/test/cases/adapters/postgresql/bit_string_test.rb +++ b/activerecord/test/cases/adapters/postgresql/bit_string_test.rb @@ -30,7 +30,6 @@ class PostgresqlBitStringTest < ActiveRecord::TestCase assert_not column.array? type = PostgresqlBitString.type_for_attribute("a_bit") - assert_not type.number? assert_not type.binary? end @@ -41,7 +40,6 @@ class PostgresqlBitStringTest < ActiveRecord::TestCase assert_not column.array? type = PostgresqlBitString.type_for_attribute("a_bit_varying") - assert_not type.number? assert_not type.binary? end diff --git a/activerecord/test/cases/adapters/postgresql/citext_test.rb b/activerecord/test/cases/adapters/postgresql/citext_test.rb index 077f0271e2..0ee2a21484 100644 --- a/activerecord/test/cases/adapters/postgresql/citext_test.rb +++ b/activerecord/test/cases/adapters/postgresql/citext_test.rb @@ -34,7 +34,6 @@ if ActiveRecord::Base.connection.supports_extensions? assert_not column.array? type = Citext.type_for_attribute('cival') - assert_not type.number? assert_not type.binary? end diff --git a/activerecord/test/cases/adapters/postgresql/composite_test.rb b/activerecord/test/cases/adapters/postgresql/composite_test.rb index 0c0d2465b2..83dfb18e95 100644 --- a/activerecord/test/cases/adapters/postgresql/composite_test.rb +++ b/activerecord/test/cases/adapters/postgresql/composite_test.rb @@ -52,7 +52,6 @@ class PostgresqlCompositeTest < ActiveRecord::TestCase assert_not column.array? type = PostgresqlComposite.type_for_attribute("address") - assert_not type.number? assert_not type.binary? end @@ -115,7 +114,6 @@ class PostgresqlCompositeWithCustomOIDTest < ActiveRecord::TestCase assert_not column.array? type = PostgresqlComposite.type_for_attribute("address") - assert_not type.number? assert_not type.binary? end diff --git a/activerecord/test/cases/adapters/postgresql/domain_test.rb b/activerecord/test/cases/adapters/postgresql/domain_test.rb index 702de07597..b7d776b40c 100644 --- a/activerecord/test/cases/adapters/postgresql/domain_test.rb +++ b/activerecord/test/cases/adapters/postgresql/domain_test.rb @@ -31,7 +31,6 @@ class PostgresqlDomainTest < ActiveRecord::TestCase assert_not column.array? type = PostgresqlDomain.type_for_attribute("price") - assert type.number? assert_not type.binary? end diff --git a/activerecord/test/cases/adapters/postgresql/enum_test.rb b/activerecord/test/cases/adapters/postgresql/enum_test.rb index 7739d2ee3b..acb09b0607 100644 --- a/activerecord/test/cases/adapters/postgresql/enum_test.rb +++ b/activerecord/test/cases/adapters/postgresql/enum_test.rb @@ -33,7 +33,6 @@ class PostgresqlEnumTest < ActiveRecord::TestCase assert_not column.array? type = PostgresqlEnum.type_for_attribute("current_mood") - assert_not type.number? assert_not type.binary? end diff --git a/activerecord/test/cases/adapters/postgresql/full_text_test.rb b/activerecord/test/cases/adapters/postgresql/full_text_test.rb index 8357dcb3dc..81891a90fa 100644 --- a/activerecord/test/cases/adapters/postgresql/full_text_test.rb +++ b/activerecord/test/cases/adapters/postgresql/full_text_test.rb @@ -23,7 +23,6 @@ class PostgresqlFullTextTest < ActiveRecord::TestCase assert_not column.array? type = Tsvector.type_for_attribute("text_vector") - assert_not type.number? assert_not type.binary? end diff --git a/activerecord/test/cases/adapters/postgresql/geometric_test.rb b/activerecord/test/cases/adapters/postgresql/geometric_test.rb index 5d2e86c5a0..4b25381a83 100644 --- a/activerecord/test/cases/adapters/postgresql/geometric_test.rb +++ b/activerecord/test/cases/adapters/postgresql/geometric_test.rb @@ -28,7 +28,6 @@ class PostgresqlPointTest < ActiveRecord::TestCase assert_not column.array? type = PostgresqlPoint.type_for_attribute("x") - assert_not type.number? assert_not type.binary? end diff --git a/activerecord/test/cases/adapters/postgresql/hstore_test.rb b/activerecord/test/cases/adapters/postgresql/hstore_test.rb index 121f347986..11053a6e38 100644 --- a/activerecord/test/cases/adapters/postgresql/hstore_test.rb +++ b/activerecord/test/cases/adapters/postgresql/hstore_test.rb @@ -56,7 +56,6 @@ if ActiveRecord::Base.connection.supports_extensions? assert_equal "hstore", @column.sql_type assert_not @column.array? - assert_not @type.number? assert_not @type.binary? end diff --git a/activerecord/test/cases/adapters/postgresql/json_test.rb b/activerecord/test/cases/adapters/postgresql/json_test.rb index dd7b67bad7..cbe7e62870 100644 --- a/activerecord/test/cases/adapters/postgresql/json_test.rb +++ b/activerecord/test/cases/adapters/postgresql/json_test.rb @@ -36,7 +36,6 @@ module PostgresqlJSONSharedTestCases assert_not column.array? type = JsonDataType.type_for_attribute("payload") - assert_not type.number? assert_not type.binary? end diff --git a/activerecord/test/cases/adapters/postgresql/ltree_test.rb b/activerecord/test/cases/adapters/postgresql/ltree_test.rb index ca17edfd03..2b3823f9f1 100644 --- a/activerecord/test/cases/adapters/postgresql/ltree_test.rb +++ b/activerecord/test/cases/adapters/postgresql/ltree_test.rb @@ -32,7 +32,6 @@ class PostgresqlLtreeTest < ActiveRecord::TestCase assert_not column.array? type = Ltree.type_for_attribute('path') - assert_not type.number? assert_not type.binary? end diff --git a/activerecord/test/cases/adapters/postgresql/money_test.rb b/activerecord/test/cases/adapters/postgresql/money_test.rb index f5621fd3ec..ba9af4be6f 100644 --- a/activerecord/test/cases/adapters/postgresql/money_test.rb +++ b/activerecord/test/cases/adapters/postgresql/money_test.rb @@ -27,7 +27,6 @@ class PostgresqlMoneyTest < ActiveRecord::TestCase assert_not column.array? type = PostgresqlMoney.type_for_attribute("wealth") - assert type.number? assert_not type.binary? end diff --git a/activerecord/test/cases/adapters/postgresql/network_test.rb b/activerecord/test/cases/adapters/postgresql/network_test.rb index efe754ac7c..4cd2d4d5f3 100644 --- a/activerecord/test/cases/adapters/postgresql/network_test.rb +++ b/activerecord/test/cases/adapters/postgresql/network_test.rb @@ -25,7 +25,6 @@ class PostgresqlNetworkTest < ActiveRecord::TestCase assert_not column.array? type = PostgresqlNetworkAddress.type_for_attribute("cidr_address") - assert_not type.number? assert_not type.binary? end @@ -36,7 +35,6 @@ class PostgresqlNetworkTest < ActiveRecord::TestCase assert_not column.array? type = PostgresqlNetworkAddress.type_for_attribute("inet_address") - assert_not type.number? assert_not type.binary? end @@ -47,7 +45,6 @@ class PostgresqlNetworkTest < ActiveRecord::TestCase assert_not column.array? type = PostgresqlNetworkAddress.type_for_attribute("mac_address") - assert_not type.number? assert_not type.binary? end diff --git a/activerecord/test/cases/adapters/postgresql/uuid_test.rb b/activerecord/test/cases/adapters/postgresql/uuid_test.rb index 1d0f013a26..6693843497 100644 --- a/activerecord/test/cases/adapters/postgresql/uuid_test.rb +++ b/activerecord/test/cases/adapters/postgresql/uuid_test.rb @@ -51,7 +51,6 @@ class PostgresqlUUIDTest < ActiveRecord::TestCase assert_not column.array? type = UUIDType.type_for_attribute("guid") - assert_not type.number? assert_not type.binary? end |