aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2014-07-18 00:49:57 +0930
committerMatthew Draper <matthew@trebex.net>2014-07-18 00:49:57 +0930
commit58427d9330ff4d189ed5bd667fdeae5a2dadc9c0 (patch)
tree4109ececb7f1806c2d77b41b1bbb5add49dccec9
parent719701d617abbf87f24f8de8655a7ad3657e6533 (diff)
parent8c263d53b3b9d190a8ae564ca043b96b76c76877 (diff)
downloadrails-58427d9330ff4d189ed5bd667fdeae5a2dadc9c0.tar.gz
rails-58427d9330ff4d189ed5bd667fdeae5a2dadc9c0.tar.bz2
rails-58427d9330ff4d189ed5bd667fdeae5a2dadc9c0.zip
Merge pull request #16198 from eileencodes/remove-need-for-macro-instance-var
Remove need for macro instance var
-rw-r--r--activerecord/lib/active_record/reflection.rb25
1 files changed, 14 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 12208aecf7..2eefba2dfe 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -177,12 +177,6 @@ module ActiveRecord
# <tt>has_many :clients</tt> returns <tt>:clients</tt>
attr_reader :name
- # Returns the macro type.
- #
- # <tt>composed_of :balance, class_name: 'Money'</tt> returns <tt>:composed_of</tt>
- # <tt>has_many :clients</tt> returns <tt>:has_many</tt>
- attr_reader :macro
-
attr_reader :scope
# Returns the hash of options used for the macro.
@@ -386,7 +380,7 @@ Joining, Preloading and eager loading of these associations is deprecated and wi
scope ? [[scope]] : [[]]
end
- alias :source_macro :macro
+ def source_macro; macro; end
def has_inverse?
inverse_name
@@ -408,6 +402,11 @@ Joining, Preloading and eager loading of these associations is deprecated and wi
end
end
+ # Returns the macro type.
+ #
+ # <tt>has_many :clients</tt> returns <tt>:has_many</tt>
+ def macro; raise NotImplementedError; end
+
# Returns whether or not this association reflection is for a collection
# association. Returns +true+ if the +macro+ is either +has_many+ or
# +has_and_belongs_to_many+, +false+ otherwise.
@@ -578,10 +577,11 @@ Joining, Preloading and eager loading of these associations is deprecated and wi
class HasManyReflection < AssociationReflection #:nodoc:
def initialize(name, scope, options, active_record)
- @macro = :has_many
super(name, scope, options, active_record)
end
+ def macro; :has_many; end
+
def collection?
true
end
@@ -589,24 +589,27 @@ Joining, Preloading and eager loading of these associations is deprecated and wi
class HasOneReflection < AssociationReflection #:nodoc:
def initialize(name, scope, options, active_record)
- @macro = :has_one
super(name, scope, options, active_record)
end
+
+ def macro; :has_one; end
end
class BelongsToReflection < AssociationReflection #:nodoc:
def initialize(name, scope, options, active_record)
- @macro = :belongs_to
super(name, scope, options, active_record)
end
+
+ def macro; :belongs_to; end
end
class HasAndBelongsToManyReflection < AssociationReflection #:nodoc:
def initialize(name, scope, options, active_record)
- @macro = :has_and_belongs_to_many
super
end
+ def macro; :has_and_belongs_to_many; end
+
def collection?
true
end