Module: Paranoid::JoinAssociation

Extended by:
ActiveSupport::Concern
Defined in:
lib/paranoid/join_association.rb

Instance Method Summary collapse

Instance Method Details

#association_join_with_paranoidObject

Overrides ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation#association_join adding paranoid conditions when necessary



11
12
13
14
15
16
17
18
19
20
# File 'lib/paranoid/join_association.rb', line 11

def association_join_with_paranoid
  return @join if @join
  result = association_join_without_paranoid
  if reflection.klass.paranoid?
    aliased_table = Arel::Table.new(table_name, :as => @aliased_table_name, :engine => arel_engine)
    pb = ActiveRecord::PredicateBuilder.new(arel_engine)
    result.concat(pb.build_from_hash(reflection.klass.paranoid_condition, aliased_table))
  end
  result
end