Sha256: f838ebe5ad6a0a5c6a37710f721013e7d2d39990c50e90aa7407ebf70be962d5

Contents?: true

Size: 857 Bytes

Versions: 1

Compression:

Stored size: 857 Bytes

Contents

require 'hammer_cli/messages'

module HammerCLI::Apipie

  class WriteCommand < Command

    include HammerCLI::Messages

    def execute
      print_success_message(send_request)
      return HammerCLI::EX_OK
    end

    protected

    def success_message_params(response)
      response
    end

    def print_success_message(response)
      if success_message
        print_message(
          success_message,
          success_message_params(response)
        )
      end
    end

    def send_request
      if resource && resource.has_action?(action)
        resource.call(action, request_params, request_headers)
      else
        raise HammerCLI::OperationNotSupportedError, "The server does not support such operation."
      end
    end

    def request_headers
      {}
    end

    def request_params
      method_options
    end

  end

end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hammer_cli-0.1.0 lib/hammer_cli/apipie/write_command.rb