Skip to content

Commit

Permalink
standardize use of instance variable
Browse files Browse the repository at this point in the history
  • Loading branch information
seamusabshere committed Feb 1, 2011
1 parent 76891a0 commit 34ace6a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/cohort_scope/cohort.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ def sanitize_constraints(model, constraints)
#
# For example, :car => <#Car> might get translated into :car_id => 44 or :car_type => 44 if :foreign_key option is given.
def association_foreign_key(model, name)
@_cohort_association_foreign_keys ||= {}
return @_cohort_association_foreign_keys[name] if @_cohort_association_foreign_keys.has_key? name
@association_foreign_key ||= {}
return @association_foreign_key[name] if @association_foreign_key.has_key? name
association = model.reflect_on_association name
raise "there is no association #{name.inspect} on #{model}" if association.nil?
raise "can't use cohort scope on :through associations (#{self.name} #{name})" if association.options.has_key? :through
foreign_key = association.instance_variable_get(:@options)[:foreign_key]
if !foreign_key.blank?
@_cohort_association_foreign_keys[name] = foreign_key
@association_foreign_key[name] = foreign_key
else
@_cohort_association_foreign_keys[name] = association.primary_key_name
@association_foreign_key[name] = association.primary_key_name
end
end

Expand Down

0 comments on commit 34ace6a

Please sign in to comment.