Class: Serega::SeregaBatch::AutoResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/serega/batch/auto_resolver.rb

Overview

Automatically generated resolver for batch_loader

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(loader_name, id_method) ⇒ AutoResolver

Returns a new instance of AutoResolver.



12
13
14
15
# File 'lib/serega/batch/auto_resolver.rb', line 12

def initialize(loader_name, id_method)
  @loader_name = loader_name
  @id_method = id_method
end

Instance Attribute Details

#id_methodObject (readonly)

Returns the value of attribute id_method.



10
11
12
# File 'lib/serega/batch/auto_resolver.rb', line 10

def id_method
  @id_method
end

#loader_nameObject (readonly)

Returns the value of attribute loader_name.



9
10
11
# File 'lib/serega/batch/auto_resolver.rb', line 9

def loader_name
  @loader_name
end

Instance Method Details

#call(obj, batches:) ⇒ Object

Finds object attribute value from hash of batch_loaded values for all serialized objects



19
20
21
# File 'lib/serega/batch/auto_resolver.rb', line 19

def call(obj, batches:)
  batches.fetch(loader_name)[obj.public_send(id_method)]
end