Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Let AttributeMethods do its own including etc

  • Loading branch information...
commit 17ad71e5141eaa79bfb4aedc2f3a5b4abfa0baba 1 parent ceb33f8
@jonleighton jonleighton authored
View
23 activerecord/lib/active_record/attribute_methods.rb
@@ -7,6 +7,29 @@ module AttributeMethods #:nodoc:
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
17 activerecord/lib/active_record/base.rb
@@ -696,12 +696,6 @@ def to_ary # :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 @@ def to_ary # :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
6 activerecord/test/cases/attribute_methods/read_test.rb
@@ -14,8 +14,9 @@ def type; :integer; end
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 @@ def self.columns_hash
[name, FakeColumn.new(name)]
}]
end
-
- def self.serialized_attributes; {}; end
- def self.base_class; self; end
end
end

0 comments on commit 17ad71e

Please sign in to comment.
Something went wrong with that request. Please try again.