Class: ApiConstraints

Inherits:
Object
  • Object
show all
Defined in:
lib/api_constraints.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ApiConstraints

Returns a new instance of ApiConstraints.



2
3
4
5
# File 'lib/api_constraints.rb', line 2

def initialize(options)
  @version = options[:version]
  @default = options[:default]
end

Instance Method Details

#matches?(req) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/api_constraints.rb', line 7

def matches?(req)
  @default || req.headers['Accept'].include?("application/vnd.example.v#{@version}")
end