Class: OpenStax::Api::Constraints
- Inherits:
-
Object
- Object
- OpenStax::Api::Constraints
- Defined in:
- lib/openstax/api/constraints.rb
Instance Method Summary collapse
- #api_accept_header ⇒ Object
-
#initialize(options) ⇒ Constraints
constructor
A new instance of Constraints.
- #matches?(req) ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Constraints
Returns a new instance of Constraints.
6 7 8 9 |
# File 'lib/openstax/api/constraints.rb', line 6 def initialize() @version = [:version] @default = [:default] end |
Instance Method Details
#api_accept_header ⇒ Object
11 12 13 |
# File 'lib/openstax/api/constraints.rb', line 11 def api_accept_header "application/vnd.openstax.#{@version.to_s}" end |
#matches?(req) ⇒ Boolean
15 16 17 |
# File 'lib/openstax/api/constraints.rb', line 15 def matches?(req) !!(@default || req.headers['Accept'].try(:include?, api_accept_header)) end |