Permalink
Browse files

add inversed accessor to association class

  • Loading branch information...
1 parent 05b1780 commit 3a6cf83b9a0d9481d9bfa87afea2155e524e0596 @dmitry dmitry committed May 12, 2013
Showing with 3 additions and 2 deletions.
  1. +3 −2 activerecord/lib/active_record/associations/association.rb
@@ -17,6 +17,7 @@ module Associations
# HasManyThroughAssociation + ThroughAssociation
class Association #:nodoc:
attr_reader :owner, :target, :reflection
+ attr_accessor :inversed
delegate :options, :to => :reflection
@@ -72,7 +73,7 @@ def loaded!
#
# Note that if the target has not been loaded, it is not considered stale.
def stale_target?
- !@inversed && loaded? && @stale_state != stale_state
+ !inversed && loaded? && @stale_state != stale_state
end
# 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)
if record && invertible_for?(record)
inverse = record.association(inverse_reflection_for(record).name)
inverse.target = owner
- inverse.instance_variable_set(:@inversed, true)
+ inverse.inversed = true
end
end

0 comments on commit 3a6cf83

Please sign in to comment.