Class: Sparrow::Steward
- Inherits:
-
Object
- Object
- Sparrow::Steward
- Defined in:
- lib/sparrow/steward.rb
Overview
this class is requested to be removed by issue #7 in the feature and
Parses the http_mesage and provides information if it should be processed, i.e. if the content type or accept header is applicable
its internal will be moved to its counterparts such as HttpMessage itself.
Direct Known Subclasses
Instance Attribute Summary collapse
- #allowed_accepts ⇒ Array<String> readonly
- #allowed_content_types ⇒ Array<String> readonly
- #excluded_routes ⇒ Array<String,Regexp> readonly
-
#http_message ⇒ HttpMessage
readonly
The wrapped http message object to be checked.
- #ignored_response_codes ⇒ Array<Integer> readonly
-
#route_parser ⇒ RouteParser
readonly
The route parser for the #excluded_routes.
Instance Method Summary collapse
-
#has_processable_http_message? ⇒ Boolean
Checks the
http_messageagainst any given criteria specified by theoptionswithin the constructor. -
#initialize(http_message, options = {}) ⇒ Steward
constructor
Initialize the Steward with the HTTP message to check and the specific check options.
Constructor Details
#initialize(http_message, options = {}) ⇒ Steward
Initialize the Steward with the HTTP message to check and the specific check options.
56 57 58 59 60 61 62 63 |
# File 'lib/sparrow/steward.rb', line 56 def initialize(, = {}) = @allowed_accepts = .fetch(:allowed_accepts, []) @allowed_content_types = .fetch(:allowed_content_types, []) @excluded_routes = .fetch(:excluded_routes, []) @ignored_response_codes = .fetch(:ignored_response_codes, []) @route_parser = RouteParser.new(excluded_routes) end |
Instance Attribute Details
#allowed_accepts ⇒ Array<String> (readonly)
17 18 19 |
# File 'lib/sparrow/steward.rb', line 17 def allowed_accepts @allowed_accepts end |
#allowed_content_types ⇒ Array<String> (readonly)
22 23 24 |
# File 'lib/sparrow/steward.rb', line 22 def allowed_content_types @allowed_content_types end |
#excluded_routes ⇒ Array<String,Regexp> (readonly)
27 28 29 |
# File 'lib/sparrow/steward.rb', line 27 def excluded_routes @excluded_routes end |
#http_message ⇒ HttpMessage (readonly)
12 13 14 |
# File 'lib/sparrow/steward.rb', line 12 def end |
#ignored_response_codes ⇒ Array<Integer> (readonly)
32 33 34 |
# File 'lib/sparrow/steward.rb', line 32 def ignored_response_codes @ignored_response_codes end |
#route_parser ⇒ RouteParser (readonly)
Returns the route parser for the #excluded_routes.
37 38 39 |
# File 'lib/sparrow/steward.rb', line 37 def route_parser @route_parser end |
Instance Method Details
#has_processable_http_message? ⇒ Boolean
Checks the http_message against any given criteria specified by the options within the constructor
70 71 72 73 74 |
# File 'lib/sparrow/steward.rb', line 70 def includes_route? && allowed_content_type? && allowed_accept_header? end |