Class: Rack::Raml::Response
- Inherits:
-
Object
- Object
- Rack::Raml::Response
- Defined in:
- lib/rack/raml/response.rb
Instance Attribute Summary collapse
-
#raml ⇒ Object
readonly
Returns the value of attribute raml.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
-
#initialize(raml_file, request) ⇒ Response
constructor
A new instance of Response.
- #matches? ⇒ Boolean
- #to_rack ⇒ Object
Constructor Details
#initialize(raml_file, request) ⇒ Response
Returns a new instance of Response.
9 10 11 12 |
# File 'lib/rack/raml/response.rb', line 9 def initialize(raml_file, request) @raml = ::Raml.parse_file(raml_file) @request = request end |
Instance Attribute Details
#raml ⇒ Object (readonly)
Returns the value of attribute raml.
7 8 9 |
# File 'lib/rack/raml/response.rb', line 7 def raml @raml end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
7 8 9 |
# File 'lib/rack/raml/response.rb', line 7 def request @request end |
Instance Method Details
#matches? ⇒ Boolean
14 15 16 |
# File 'lib/rack/raml/response.rb', line 14 def matches? !response.nil? end |
#to_rack ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/rack/raml/response.rb', line 18 def to_rack if matches? [code, { 'Content-Type' => type }, [body]] else [404, { 'Content-Type' => type }, [not_found]] end end |