Sha256: b286698db869e3adb852d8290cca220ae71d3cc7c0386b77bbc0360eb245375e
Contents?: true
Size: 1.27 KB
Versions: 5
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true module GraphqlDevise module MountMethod module OperationPreparers class DefaultOperationPreparer def initialize(selected_operations:, custom_keys:, model:, preparer:) @selected_operations = selected_operations @custom_keys = custom_keys @model = model @preparer = preparer end def call mapping_name = GraphqlDevise.to_mapping_name(@model) @selected_operations.except(*@custom_keys).each_with_object({}) do |(action, operation_info), result| mapped_action = "#{mapping_name}_#{action}" operation = operation_info[:klass] options = operation_info.except(:klass, :deprecation_reason) result[mapped_action.to_sym] = [ OperationPreparers::GqlNameSetter.new(mapped_action), @preparer, OperationPreparers::ResourceKlassSetter.new(@model) ].reduce(child_class(operation)) do |prepared_operation, preparer| preparer.call(prepared_operation, **options) end end end private def child_class(operation) Class.new(operation) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems