Class: EagerGroup::Preloader::AggregationFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/eager_group/preloader/aggregation_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, definition, arguments, records) ⇒ AggregationFinder

Returns a new instance of AggregationFinder.



8
9
10
11
12
13
14
# File 'lib/eager_group/preloader/aggregation_finder.rb', line 8

def initialize(klass, definition, arguments, records)
  @klass = klass
  @definition = definition
  @reflection = @klass.reflect_on_association(definition.association)
  @arguments = arguments
  @records = records
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



6
7
8
# File 'lib/eager_group/preloader/aggregation_finder.rb', line 6

def arguments
  @arguments
end

#definitionObject (readonly)

Returns the value of attribute definition.



6
7
8
# File 'lib/eager_group/preloader/aggregation_finder.rb', line 6

def definition
  @definition
end

#klassObject (readonly)

Returns the value of attribute klass.



6
7
8
# File 'lib/eager_group/preloader/aggregation_finder.rb', line 6

def klass
  @klass
end

#record_idsObject (readonly)

Returns the value of attribute record_ids.



6
7
8
# File 'lib/eager_group/preloader/aggregation_finder.rb', line 6

def record_ids
  @record_ids
end

#reflectionObject (readonly)

Returns the value of attribute reflection.



6
7
8
# File 'lib/eager_group/preloader/aggregation_finder.rb', line 6

def reflection
  @reflection
end

Instance Method Details

#definition_scopeObject



16
17
18
# File 'lib/eager_group/preloader/aggregation_finder.rb', line 16

def definition_scope
  reflection.klass.instance_exec(*arguments, &definition.scope) if definition.scope
end

#group_by_keyObject



24
25
26
# File 'lib/eager_group/preloader/aggregation_finder.rb', line 24

def group_by_key
  @klass.primary_key
end