Class: PluckMap::AssociationScope::Current

Inherits:
ActiveRecord::Associations::AssociationScope
  • Object
show all
Defined in:
lib/pluck_map/association_scope.rb

Overview

Rails 5.1+

Direct Known Subclasses

Rails42, Rails50

Instance Method Summary collapse

Instance Method Details

#apply_scope(scope, table, key, value) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/pluck_map/association_scope.rb', line 26

def apply_scope(scope, table, key, value)
  if value.is_a?(Arel::Attributes::Attribute)
    scope.where!(table[key].eq(value))
  else
    super
  end
end

#scope(association) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/pluck_map/association_scope.rb', line 34

def scope(association)
  if ActiveRecord.version.version < "5.2"
    super(association, association.reflection.active_record.connection)
  else
    super
  end
end