Sha256: 416a98fc35a65668cf1c26848ebbe81470b1b903535844a9f25aac3f5fc5a3e0

Contents?: true

Size: 1.53 KB

Versions: 6

Compression:

Stored size: 1.53 KB

Contents

module Ecoportal
  module API
    class GraphQL
      module Input
        module LocationStructure
          class ApplyCommands < Ecoportal::API::GraphQL::Base::Model
            passkey :id
            passthrough :clientMutationId
            passboolean :force
            embeds_many :commands, klass: Ecoportal::API::GraphQL::Input::LocationStructure::CommandInterface
            passboolean :preview

            def add(type, **kargs)
              if (command = new_command(type))
                command.set_values(**kargs) unless kargs.empty?
                yield(command) if block_given?
              end
              command
            end

            private

            def new_command(type)
              case type
              when :archive
                Input::LocationStructure::ArchiveCommand.new
              when :unarchive
                Input::LocationStructure::UnarchiveCommand.new
              when :delete
                Input::LocationStructure::DeleteCommand.new
              when :move
                Input::LocationStructure::MoveCommand.new
              when :insert
                Input::LocationStructure::InsertCommand.new
              when :update
                Input::LocationStructure::UpdateCommand.new
              when :reoder
                Input::LocationStructure::ReoderCommand.new
              else
                raise "Unknown command type: '#{type}'"
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ecoportal-api-graphql-0.4.3 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.4.2 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.4.1 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.4.0 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.3.16 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.3.15 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb