Sha256: 8fb314e97c62d71425d8c70fd073d86c54d68741d4e614e106e778183ce8a68b

Contents?: true

Size: 885 Bytes

Versions: 11

Compression:

Stored size: 885 Bytes

Contents

# frozen_string_literal: true

module GraphqlDevise
  module MountMethod
    module OperationPreparers
      class CustomOperationPreparer
        def initialize(selected_keys:, custom_operations:, mapping_name:)
          @selected_keys     = selected_keys
          @custom_operations = custom_operations
          @mapping_name      = mapping_name
        end

        def call
          @custom_operations.slice(*@selected_keys).each_with_object({}) do |(action, operation), result|
            mapped_action = "#{@mapping_name}_#{action}"

            result[mapped_action.to_sym] = [
              OperationPreparers::GqlNameSetter.new(mapped_action),
              OperationPreparers::ResourceNameSetter.new(@mapping_name)
            ].reduce(operation) { |prepared_operation, preparer| preparer.call(prepared_operation) }
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
graphql_devise-0.14.3 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.14.2 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.14.1 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.14.0 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.13.6 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.13.5 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.13.4 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.13.3 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.13.2 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.13.1 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.13.0 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb