Class: ActiveAny::Associations::AssociationScope

Inherits:
Object
  • Object
show all
Defined in:
lib/active_any/associations/association_scope.rb

Constant Summary collapse

INSTANCE =
create

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.createObject



10
11
12
# File 'lib/active_any/associations/association_scope.rb', line 10

def self.create
  new
end

.scope(association) ⇒ Object



6
7
8
# File 'lib/active_any/associations/association_scope.rb', line 6

def self.scope(association)
  INSTANCE.scope(association)
end

Instance Method Details

#scope(association) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/active_any/associations/association_scope.rb', line 16

def scope(association)
  klass = association.klass
  reflection = association.reflection
  scope = klass.all
  owner = association.owner

  add_constraints(scope, owner, reflection)
end