Class: GraphqlDevise::MountMethod::OperationPreparer

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql_devise/mount_method/operation_preparer.rb

Instance Method Summary collapse

Constructor Details

#initialize(model:, selected_operations:, preparer:, custom:, additional_operations:) ⇒ OperationPreparer

Returns a new instance of OperationPreparer.



6
7
8
9
10
11
12
# File 'lib/graphql_devise/mount_method/operation_preparer.rb', line 6

def initialize(model:, selected_operations:, preparer:, custom:, additional_operations:)
  @selected_operations   = selected_operations
  @preparer              = preparer
  @model                 = model
  @custom                = custom
  @additional_operations = additional_operations
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/graphql_devise/mount_method/operation_preparer.rb', line 14

def call
  default_operations = OperationPreparers::DefaultOperationPreparer.new(
    selected_operations: @selected_operations,
    custom_keys:         @custom.keys,
    model:               @model,
    preparer:            @preparer
  ).call

  custom_operations = OperationPreparers::CustomOperationPreparer.new(
    selected_keys:     @selected_operations.keys,
    custom_operations: @custom,
    model:             @model
  ).call

  additional_operations = @additional_operations.each_with_object({}) do |(action, operation), result|
    result[action] = OperationPreparers::ResourceKlassSetter.new(@model).call(operation)
  end

  default_operations.merge(custom_operations).merge(additional_operations)
end