Sha256: 5e48912a27c6cc22da7e3cdabd42fb393e6f7949969438b9cbf42175a93e2d7e

Contents?: true

Size: 1.52 KB

Versions: 15

Compression:

Stored size: 1.52 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

15 entries across 15 versions & 1 rubygems

Version Path
ecoportal-api-graphql-0.3.14 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.3.13 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.3.12 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.3.11 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.3.10 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.3.9 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.3.8 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.3.7 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.3.6 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.3.5 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.3.3 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.3.1 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.2.3 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.2.2 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb
ecoportal-api-graphql-0.2.1 lib/ecoportal/api/graphql/input/location_structure/apply_commands.rb