Sha256: 2cd55ea3aeeb095f44efcfeaa762da2395d178c60654166169dcc3a6125ac6f1

Contents?: true

Size: 539 Bytes

Versions: 2

Compression:

Stored size: 539 Bytes

Contents

module OpenStax
  module Api
    class Constraints
      cattr_accessor :main_app_name
      
      def initialize(options)
        @version = options[:version]
        @default = options[:default]
      end

      def api_accept_header
        self.main_app_name ||= OpenStax::Api::Engine::MAIN_APP_NAME.underscore
        "application/vnd.#{self.main_app_name}.openstax.#{@version.to_s}"
      end
      
      def matches?(req)
        !!(@default || req.headers['Accept'].try(:include?, api_accept_header))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
openstax_api-2.5.1 lib/openstax/api/constraints.rb
openstax_api-2.5.0 lib/openstax/api/constraints.rb