1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Let AttributeMethods do its own including etc

This commit is contained in:
Jon Leighton 2011-12-15 20:21:05 +00:00
parent ceb33f8493
commit 17ad71e514
3 changed files with 25 additions and 21 deletions

View file

@ -7,6 +7,29 @@ module ActiveRecord
extend ActiveSupport::Concern
include ActiveModel::AttributeMethods
included do
include Read
include Write
include BeforeTypeCast
include Query
include PrimaryKey
include TimeZoneConversion
include Dirty
include Serialization
include DeprecatedUnderscoreRead
# Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example,
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
# (Alias for the protected read_attribute method).
alias [] read_attribute
# Updates the attribute identified by <tt>attr_name</tt> with the specified +value+.
# (Alias for the protected write_attribute method).
alias []= write_attribute
public :[], :[]=
end
module ClassMethods
# Generates all the attribute related methods for columns in the database
# accessors, mutators and query methods.

View file

@ -696,12 +696,6 @@ module ActiveRecord #:nodoc:
extend CounterCache
include Locking::Optimistic, Locking::Pessimistic
include AttributeMethods
include AttributeMethods::Read, AttributeMethods::Write, AttributeMethods::BeforeTypeCast, AttributeMethods::Query
include AttributeMethods::PrimaryKey
include AttributeMethods::TimeZoneConversion
include AttributeMethods::Dirty
include AttributeMethods::Serialization
include AttributeMethods::DeprecatedUnderscoreRead
include Callbacks, ActiveModel::Observing, Timestamp
include Associations, NamedScope
include IdentityMap
@ -712,17 +706,6 @@ module ActiveRecord #:nodoc:
# #save_with_autosave_associations to be wrapped inside a transaction.
include AutosaveAssociation, NestedAttributes
include Aggregations, Transactions, Reflection, Serialization, Store
# Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example,
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
# (Alias for the protected read_attribute method).
alias [] read_attribute
# Updates the attribute identified by <tt>attr_name</tt> with the specified +value+.
# (Alias for the protected write_attribute method).
alias []= write_attribute
public :[], :[]=
end
end

View file

@ -14,8 +14,9 @@ module ActiveRecord
def setup
@klass = Class.new do
def self.base_class; self; end
include ActiveRecord::AttributeMethods
include ActiveRecord::AttributeMethods::Read
def self.column_names
%w{ one two three }
@ -33,9 +34,6 @@ module ActiveRecord
[name, FakeColumn.new(name)]
}]
end
def self.serialized_attributes; {}; end
def self.base_class; self; end
end
end