Class: OccamsRecord::EagerLoaders::Tracer

Inherits:
Struct
  • Object
show all
Defined in:
lib/occams-record/eager_loaders/tracer.rb

Overview

A low-memory way to trace the path of eager loads from any point back to the root query

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/occams-record/eager_loaders/tracer.rb', line 4

def name
  @name
end

#parentObject

Returns the value of attribute parent

Returns:

  • (Object)

    the current value of parent



4
5
6
# File 'lib/occams-record/eager_loaders/tracer.rb', line 4

def parent
  @parent
end

#throughObject

Returns the value of attribute through

Returns:

  • (Object)

    the current value of through



4
5
6
# File 'lib/occams-record/eager_loaders/tracer.rb', line 4

def through
  @through
end

Instance Method Details

#lookup(trace = self) ⇒ Object



9
10
11
12
13
# File 'lib/occams-record/eager_loaders/tracer.rb', line 9

def lookup(trace = self)
  return [] if trace.nil?
  name = trace.through ? "through(#{trace.name})" : trace.name
  lookup(trace.parent) << name
end

#to_sObject



5
6
7
# File 'lib/occams-record/eager_loaders/tracer.rb', line 5

def to_s
  lookup.join(".")
end