Class: Scrooge::Callsite

Inherits:
Object
  • Object
show all
Defined in:
lib/callsite.rb

Constant Summary collapse

Mtx =

Represents a Callsite and is a container for any columns and associations referenced at the callsite.

Mutex.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, signature) ⇒ Callsite

Returns a new instance of Callsite.



15
16
17
18
# File 'lib/callsite.rb', line 15

def initialize( klass, signature )
  @klass = klass
  @signature = signature
end

Instance Attribute Details

#associationsObject

Lazy init associations



54
55
56
# File 'lib/callsite.rb', line 54

def associations
  @associations
end

#columnsObject

Lazy init columns



48
49
50
# File 'lib/callsite.rb', line 48

def columns
  @columns
end

#klassObject

Returns the value of attribute klass.



10
11
12
# File 'lib/callsite.rb', line 10

def klass
  @klass
end

#signatureObject

Returns the value of attribute signature.



10
11
12
# File 'lib/callsite.rb', line 10

def signature
  @signature
end

Instance Method Details

#association!(association) ⇒ Object

Flag an association as seen



30
31
32
33
34
# File 'lib/callsite.rb', line 30

def association!( association )
  Mtx.synchronize do
    associations << association if preloadable_association?( association )
  end
end

#column!(column) ⇒ Object

Flag a column as seen



22
23
24
25
26
# File 'lib/callsite.rb', line 22

def column!( column )
  Mtx.synchronize do 
    columns << column
  end
end

#default_columnsObject

Lazy init default columns



42
43
44
# File 'lib/callsite.rb', line 42

def default_columns
  @default_columns ||= setup_columns
end

#inspectObject



36
37
38
# File 'lib/callsite.rb', line 36

def inspect
  "<##{@klass.name} :select => '#{@klass.scrooge_select_sql( columns )}', :include => [#{associations_for_inspect}]>"
end