class Yousty::HTTP::RequestMethod

A value object ensuring that the HTTP method provided is valid

Constants

InvalidMethodError
SUPPORTED_METHODS

Attributes

name[R]

Public Class Methods

new(*args, &block) click to toggle source

Initializes deeply frozen RequestMethod object @param [Symbol] a name of the HTTP method to be initialized

Calls superclass method
# File lib/yousty/http/request_method.rb, line 33
def self.new(*args, &block)
  super.deep_freeze
end
new(name) click to toggle source
# File lib/yousty/http/request_method.rb, line 41
def initialize(name)
  parsed_name = name.to_s.downcase
  raise InvalidMethodError unless SUPPORTED_METHODS.include?(parsed_name)

  @name = parsed_name
end

Public Instance Methods

==(other) click to toggle source

Compares other value with Symbol, String or other RequestMethod @param [RequestMethod|String|Symbol] @return [Boolean]

# File lib/yousty/http/request_method.rb, line 19
def ==(other)
  name == other.to_s.downcase
end
to_s() click to toggle source

Returns a unified string representation of the HTTP method @return [String]

# File lib/yousty/http/request_method.rb, line 26
def to_s
  name
end