Module: StubRequests::Concerns::RegisterVerb

Included in:
Service
Defined in:
lib/stub_requests/concerns/register_verb.rb

Overview

Module RegisterVerb provides

Author:

Since:

  • 0.1.10

Instance Method Summary collapse

Instance Method Details

#any(path, as:) ⇒ Endpoint

Convenience wrapper for register

. get("documents/:id", as: :documents_show)

Examples:

Register a get endpoint

Parameters:

  • path (String)

    the path to the endpoint

  • as (Symbol)

    the id of the endpoint

Returns:

  • (Endpoint)

    the registered endpoint

Since:

  • 0.1.10



25
26
27
# File 'lib/stub_requests/concerns/register_verb.rb', line 25

def any(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
  register(as, __method__, path)
end

#delete(path, as:) ⇒ Endpoint

Register a :delete endpoint

. delete("documents/:id", as: :documents_destroy)

Examples:

Register a delete endpoint

Parameters:

  • path (String)

    the path to the endpoint

  • as (Symbol)

    the id of the endpoint

Returns:

  • (Endpoint)

    the registered endpoint

Since:

  • 0.1.10



105
106
107
# File 'lib/stub_requests/concerns/register_verb.rb', line 105

def delete(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
  register(as, __method__, path)
end

#get(path, as:) ⇒ Endpoint

Convenience wrapper for register

. get("documents/:id", as: :documents_show)

Examples:

Register a get endpoint

Parameters:

  • path (String)

    the path to the endpoint

  • as (Symbol)

    the id of the endpoint

Returns:

  • (Endpoint)

    the registered endpoint

Since:

  • 0.1.10



41
42
43
# File 'lib/stub_requests/concerns/register_verb.rb', line 41

def get(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
  register(as, __method__, path)
end

#patch(path, as:) ⇒ Endpoint

Register a :patch endpoint

. patch("documents/:id", as: :documents_update)

Examples:

Register a patch endpoint

Parameters:

  • path (String)

    the path to the endpoint

  • as (Symbol)

    the id of the endpoint

Returns:

  • (Endpoint)

    the registered endpoint

Since:

  • 0.1.10



73
74
75
# File 'lib/stub_requests/concerns/register_verb.rb', line 73

def patch(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
  register(as, __method__, path)
end

#post(path, as:) ⇒ Endpoint

Register a :post endpoint

. post("documents", as: :documents_create)

Examples:

Register a post endpoint

Parameters:

  • path (String)

    the path to the endpoint

  • as (Symbol)

    the id of the endpoint

Returns:

  • (Endpoint)

    the registered endpoint

Since:

  • 0.1.10



57
58
59
# File 'lib/stub_requests/concerns/register_verb.rb', line 57

def post(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
  register(as, __method__, path)
end

#put(path, as:) ⇒ Endpoint

Register a :put endpoint

. put("documents/:id", as: :documents_update)

Examples:

Register a put endpoint

Parameters:

  • path (String)

    the path to the endpoint

  • as (Symbol)

    the id of the endpoint

Returns:

  • (Endpoint)

    the registered endpoint

Since:

  • 0.1.10



89
90
91
# File 'lib/stub_requests/concerns/register_verb.rb', line 89

def put(path, as:) # rubocop:disable Naming/UncommunicativeMethodParamName
  register(as, __method__, path)
end