Class: ActiveScaffold::Tableless::AssociationScope

Inherits:
ActiveRecord::Associations::AssociationScope
  • Object
show all
Defined in:
lib/active_scaffold/tableless.rb

Constant Summary collapse

INSTANCE =
create

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.scope(association, connection) ⇒ Object


4
5
6
# File 'lib/active_scaffold/tableless.rb', line 4

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

Instance Method Details

#add_constraints(scope, owner, assoc_klass, refl, tracker) ⇒ Object


20
21
22
23
# File 'lib/active_scaffold/tableless.rb', line 20

def add_constraints(scope, owner, assoc_klass, refl, tracker)
  tracker.instance_variable_set(:@assoc_klass, assoc_klass)
  super
end

#column_for(table_name, column_name, alias_tracker = nil) ⇒ Object


9
10
11
12
13
14
15
16
17
18
# File 'lib/active_scaffold/tableless.rb', line 9

def column_for(table_name, column_name, alias_tracker = nil)
  klass = alias_tracker ? alias_tracker.connection.klass : self.klass
  if table_name == klass.table_name
    klass.columns_hash[column_name]
  elsif alias_tracker && (klass = alias_tracker.instance_variable_get(:@assoc_klass))
    klass.columns_hash[column_name]
  else # rails < 4.1
    association.klass.columns_hash[column_name]
  end
end