Sha256: c99ca4696925c239cdfe42e7489b665827fb56e4866db4872dc796c7a205cd4b

Contents?: true

Size: 854 Bytes

Versions: 9

Compression:

Stored size: 854 Bytes

Contents

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

9 entries across 9 versions & 1 rubygems

Version Path
graphql_devise-0.12.3 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.12.2 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.12.1 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.12.0 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.11.4 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.11.3 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.11.2 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.11.1 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb
graphql_devise-0.11.0 lib/graphql_devise/mount_method/operation_preparers/custom_operation_preparer.rb