diff options
-rw-r--r-- | activerecord/lib/active_record/attributes.rb (renamed from activerecord/lib/active_record/properties.rb) | 12 | ||||
-rw-r--r-- | activerecord/lib/active_record/base.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/attributes_test.rb (renamed from activerecord/test/cases/custom_properties_test.rb) | 14 | ||||
-rw-r--r-- | activerecord/test/cases/base_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/dirty_test.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 6 |
7 files changed, 25 insertions, 25 deletions
diff --git a/activerecord/lib/active_record/properties.rb b/activerecord/lib/active_record/attributes.rb index 48ee42aaca..9c80121d70 100644 --- a/activerecord/lib/active_record/properties.rb +++ b/activerecord/lib/active_record/attributes.rb @@ -1,5 +1,5 @@ module ActiveRecord - module Properties # :nodoc: + module Attributes # :nodoc: extend ActiveSupport::Concern Type = ActiveRecord::Type @@ -10,7 +10,7 @@ module ActiveRecord end module ClassMethods - # Defines or overrides a property on this model. This allows customization of + # Defines or overrides a attribute on this model. This allows customization of # Active Record's type casting behavior, as well as adding support for user defined # types. # @@ -44,7 +44,7 @@ module ActiveRecord # store_listing.price_in_cents # => BigDecimal.new(10.1) # # class StoreListing < ActiveRecord::Base - # property :price_in_cents, Type::Integer.new + # attribute :price_in_cents, Type::Integer.new # end # # # after @@ -53,7 +53,7 @@ module ActiveRecord # Users may also define their own custom types, as long as they respond to the methods # defined on the value type. The `type_cast` method on your type object will be called # with values both from the database, and from your controllers. See - # `ActiveRecord::Properties::Type::Value` for the expected API. It is recommended that your + # `ActiveRecord::Attributes::Type::Value` for the expected API. It is recommended that your # type objects inherit from an existing type, or the base value type. # # class MoneyType < ActiveRecord::Type::Integer @@ -68,12 +68,12 @@ module ActiveRecord # end # # class StoreListing < ActiveRecord::Base - # property :price_in_cents, MoneyType.new + # attribute :price_in_cents, MoneyType.new # end # # store_listing = StoreListing.new(price_in_cents: '$10.00') # store_listing.price_in_cents # => 1000 - def property(name, cast_type, options = {}) + def attribute(name, cast_type, options = {}) name = name.to_s clear_caches_calculated_from_columns # Assign a new hash to ensure that subclasses do not share a hash diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 8663544231..e8c067f758 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -20,7 +20,7 @@ require 'active_record/errors' require 'active_record/log_subscriber' require 'active_record/explain_subscriber' require 'active_record/relation/delegation' -require 'active_record/properties' +require 'active_record/attributes' module ActiveRecord #:nodoc: # = Active Record @@ -323,7 +323,7 @@ module ActiveRecord #:nodoc: include Reflection include Serialization include Store - include Properties + include Attributes include AttributeDecorators end diff --git a/activerecord/test/cases/custom_properties_test.rb b/activerecord/test/cases/attributes_test.rb index 9ba1e83df6..79ef0502cb 100644 --- a/activerecord/test/cases/custom_properties_test.rb +++ b/activerecord/test/cases/attributes_test.rb @@ -1,17 +1,17 @@ require 'cases/helper' class OverloadedType < ActiveRecord::Base - property :overloaded_float, Type::Integer.new - property :overloaded_string_with_limit, Type::String.new(limit: 50) - property :non_existent_decimal, Type::Decimal.new - property :string_with_default, Type::String.new, default: 'the overloaded default' + attribute :overloaded_float, Type::Integer.new + attribute :overloaded_string_with_limit, Type::String.new(limit: 50) + attribute :non_existent_decimal, Type::Decimal.new + attribute :string_with_default, Type::String.new, default: 'the overloaded default' end class ChildOfOverloadedType < OverloadedType end class GrandchildOfOverloadedType < ChildOfOverloadedType - property :overloaded_float, Type::Float.new + attribute :overloaded_float, Type::Float.new end class UnoverloadedType < ActiveRecord::Base @@ -54,7 +54,7 @@ module ActiveRecord assert_equal 255, UnoverloadedType.columns_hash['overloaded_string_with_limit'].limit end - def test_nonexistent_property + def test_nonexistent_attribute data = OverloadedType.new(non_existent_decimal: 1) assert_equal BigDecimal.new(1), data.non_existent_decimal @@ -98,7 +98,7 @@ module ActiveRecord assert_not klass.column_names.include?('wibble') assert_equal 5, klass.content_columns.length - klass.property :wibble, Type::Value.new + klass.attribute :wibble, Type::Value.new assert_equal 7, klass.columns.length assert klass.columns_hash.key?('wibble') diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index f01901514e..fad51f4924 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -985,9 +985,9 @@ class BasicsTest < ActiveRecord::TestCase class NumericData < ActiveRecord::Base self.table_name = 'numeric_data' - property :world_population, Type::Integer.new - property :my_house_population, Type::Integer.new - property :atoms_in_universe, Type::Integer.new + attribute :world_population, Type::Integer.new + attribute :my_house_population, Type::Integer.new + attribute :atoms_in_universe, Type::Integer.new end def test_big_decimal_conditions diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index b9445ee072..dfc6a7ec67 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -16,9 +16,9 @@ Company.has_many :accounts class NumericData < ActiveRecord::Base self.table_name = 'numeric_data' - property :world_population, Type::Integer.new - property :my_house_population, Type::Integer.new - property :atoms_in_universe, Type::Integer.new + attribute :world_population, Type::Integer.new + attribute :my_house_population, Type::Integer.new + attribute :atoms_in_universe, Type::Integer.new end class CalculationsTest < ActiveRecord::TestCase diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb index 987c55ebc2..2beac84fb1 100644 --- a/activerecord/test/cases/dirty_test.rb +++ b/activerecord/test/cases/dirty_test.rb @@ -631,7 +631,7 @@ class DirtyTest < ActiveRecord::TestCase model_class = Class.new(ActiveRecord::Base) do self.table_name = 'numeric_data' - property :foo, type.new, default: 1 + attribute :foo, type.new, default: 1 end model = model_class.new diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 5b4531846d..9855835e27 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -13,10 +13,10 @@ require MIGRATIONS_ROOT + "/decimal/1_give_me_big_numbers" class BigNumber < ActiveRecord::Base unless current_adapter?(:PostgreSQLAdapter, :SQLite3Adapter) - property :value_of_e, Type::Integer.new + attribute :value_of_e, Type::Integer.new end - property :world_population, Type::Integer.new - property :my_house_population, Type::Integer.new + attribute :world_population, Type::Integer.new + attribute :my_house_population, Type::Integer.new end class Reminder < ActiveRecord::Base; end |