diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-10-08 23:44:42 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-10-08 23:44:42 -0300 |
commit | 154c60682437e940fd7953e1bb83c2c09248f2b6 (patch) | |
tree | 3275ba609219bfb1e4640f4c45a73f5ea22b2094 /activerecord | |
parent | 2f6cc48b34f892d7608cb68e4cd0b7f5aabb5d03 (diff) | |
download | rails-154c60682437e940fd7953e1bb83c2c09248f2b6.tar.gz rails-154c60682437e940fd7953e1bb83c2c09248f2b6.tar.bz2 rails-154c60682437e940fd7953e1bb83c2c09248f2b6.zip |
Move define_readers to class method since it doesn't need nothing from
the instance
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/builder/association.rb | 5 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/builder/collection_association.rb | 3 |
2 files changed, 3 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/builder/association.rb b/activerecord/lib/active_record/associations/builder/association.rb index 4066a1c9d3..cd4ad3cef9 100644 --- a/activerecord/lib/active_record/associations/builder/association.rb +++ b/activerecord/lib/active_record/associations/builder/association.rb @@ -84,14 +84,13 @@ module ActiveRecord::Associations::Builder # end # # Post.first.comments and Post.first.comments= methods are defined by this method... - def define_accessors(model, reflection) mixin = model.generated_feature_methods - define_readers(mixin) + self.class.define_readers(mixin, name) define_writers(mixin) end - def define_readers(mixin) + def self.define_readers(mixin, name) mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1 def #{name}(*args) association(:#{name}).reader(*args) diff --git a/activerecord/lib/active_record/associations/builder/collection_association.rb b/activerecord/lib/active_record/associations/builder/collection_association.rb index 15f9f9a65f..263bbb2c23 100644 --- a/activerecord/lib/active_record/associations/builder/collection_association.rb +++ b/activerecord/lib/active_record/associations/builder/collection_association.rb @@ -58,8 +58,7 @@ module ActiveRecord::Associations::Builder end # Defines the setter and getter methods for the collection_singular_ids. - - def define_readers(mixin) + def self.define_readers(mixin, name) super mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1 |