class Nucleo::Response

Public Class Methods

new(response) click to toggle source
# File lib/nucleo/response.rb, line 8
def initialize(response)
  @_response = response
end

Public Instance Methods

__getobj__() click to toggle source

Specify the class for Simple Delegator

@return [Faraday::Response]

# File lib/nucleo/response.rb, line 34
def __getobj__
  @_response
end
allow_header() click to toggle source

Extracts the ALLOW header from the HTTP Response

@return [String]

# File lib/nucleo/response.rb, line 41
def allow_header
  self.headers.fetch('allow', '')
end
allowed?(method) click to toggle source

Returns true if the method is allowed

@return [Boolean]

# File lib/nucleo/response.rb, line 15
def allowed?(method)
  self.allowed_methods.include?(method.upcase)
end
allowed_methods() click to toggle source

Returns an array of allowed methods

@return [Array]

# File lib/nucleo/response.rb, line 48
def allowed_methods
  self.allow_header.split(',').map(&:strip).map(&:upcase)
end
on(*statuses) { |self| ... } click to toggle source
# File lib/nucleo/response.rb, line 19
def on(*statuses, &block)
  status_code_mapper = Nucleo::Utilities::StatusCodeMapper.new(statuses)

  return unless status_code_mapper.includes?(@_response.status)

  if block_given?
    yield(self) and return
  else
    self
  end
end