Module: Smplkit::Jobs::HttpMethod

Defined in:
lib/smplkit/jobs/models.rb

Overview

HTTP verb a job uses when it fires (ADR-049).

Mirrors the jobs spec’s method enum so a job’s configuration.method field is constrained to a known value instead of accepting any string. Members are declared in alphabetical order.

Constant Summary collapse

DELETE =
"DELETE"
GET =
"GET"
PATCH =
"PATCH"
POST =
"POST"
PUT =
"PUT"
VALUES =
[DELETE, GET, PATCH, POST, PUT].freeze

Class Method Summary collapse

Class Method Details

.coerce(value) ⇒ String?

Validate and normalize an input to a wire-format string.

Parameters:

  • value (String, nil)

    a published constant or its literal string.

Returns:

  • (String, nil)

    the canonical wire value (or nil when input is nil).

Raises:

  • (ArgumentError)

    when value is not a member of VALUES.



51
52
53
54
55
56
57
58
59
# File 'lib/smplkit/jobs/models.rb', line 51

def self.coerce(value)
  return nil if value.nil?

  s = value.to_s
  return s if VALUES.include?(s)

  raise ArgumentError,
        "Unknown HttpMethod #{value.inspect}; expected one of #{VALUES.inspect}"
end