class Rack::Spec::BaseRequestHandler
Base class for providing some utility methods to handle Rack
env and JSON Schema
Public Class Methods
call(**args)
click to toggle source
Utility wrapper method
# File lib/rack/spec/base_request_handler.rb, line 6 def self.call(**args) new(**args).call end
Private Instance Methods
has_link_for_current_action?()
click to toggle source
@return [true, false] True if link is defined for the current action
# File lib/rack/spec/base_request_handler.rb, line 49 def has_link_for_current_action? !!link end
has_list_data?()
click to toggle source
@return [true, false] True if response is intended to be list data
# File lib/rack/spec/base_request_handler.rb, line 59 def has_list_data? link.rel == "instances" && !link.target_schema end
link()
click to toggle source
@return [JsonSchema::Schema::Link, nil] Link for the current action
# File lib/rack/spec/base_request_handler.rb, line 40 def link if instance_variable_defined?(:@link) @link else @link = @schema.link_for(method: method, path: path) end end
method()
click to toggle source
@return [String] HTTP request method @example
method #=> "GET"
# File lib/rack/spec/base_request_handler.rb, line 28 def method request.request_method end
path()
click to toggle source
@return [String] Request path @example
path #=> "/recipes"
# File lib/rack/spec/base_request_handler.rb, line 35 def path request.path_info end
request()
click to toggle source
Treats env as a utility object to easily extract method and path @return [Rack::Request]
# File lib/rack/spec/base_request_handler.rb, line 21 def request @request ||= Rack::Request.new(@env) end
schema_for_current_link()
click to toggle source
@return [JsonSchema::Schema] Schema
for current link, specified by targetSchema or parent schema
# File lib/rack/spec/base_request_handler.rb, line 54 def schema_for_current_link link.target_schema || link.parent end