Skip to content
This repository
Browse code

add inversed accessor to association class

  • Loading branch information...
commit 3a6cf83b9a0d9481d9bfa87afea2155e524e0596 1 parent 05b1780
Dmitry Polushkin authored May 12, 2013
5  activerecord/lib/active_record/associations/association.rb
@@ -17,6 +17,7 @@ module Associations
17 17
     #         HasManyThroughAssociation + ThroughAssociation
18 18
     class Association #:nodoc:
19 19
       attr_reader :owner, :target, :reflection
  20
+      attr_accessor :inversed
20 21
 
21 22
       delegate :options, :to => :reflection
22 23
 
@@ -72,7 +73,7 @@ def loaded!
72 73
       #
73 74
       # Note that if the target has not been loaded, it is not considered stale.
74 75
       def stale_target?
75  
-        !@inversed && loaded? && @stale_state != stale_state
  76
+        !inversed && loaded? && @stale_state != stale_state
76 77
       end
77 78
 
78 79
       # Sets the target of this association to <tt>\target</tt>, and the \loaded flag to +true+.
@@ -106,7 +107,7 @@ def set_inverse_instance(record)
106 107
         if record && invertible_for?(record)
107 108
           inverse = record.association(inverse_reflection_for(record).name)
108 109
           inverse.target = owner
109  
-          inverse.instance_variable_set(:@inversed, true)
  110
+          inverse.inversed = true
110 111
         end
111 112
       end
112 113
 

0 notes on commit 3a6cf83

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