Class: Apill::Matchers::VersionMatcher

Inherits:
Object
  • Object
show all
Includes:
GenericMatcher
Defined in:
lib/apill/matchers/version_matcher.rb

Instance Attribute Summary collapse

Attributes included from GenericMatcher

#accept_header, #application

Instance Method Summary collapse

Methods included from GenericMatcher

#initialize

Instance Attribute Details

#default_versionObject

Returns the value of attribute default_version.



9
10
11
# File 'lib/apill/matchers/version_matcher.rb', line 9

def default_version
  @default_version
end

#version_constraintObject

Returns the value of attribute version_constraint.



9
10
11
# File 'lib/apill/matchers/version_matcher.rb', line 9

def version_constraint
  @version_constraint
end

Instance Method Details

#matches?(request) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



12
13
14
15
16
17
18
19
# File 'lib/apill/matchers/version_matcher.rb', line 12

def matches?(request)
  super

  raise Apill::Errors::InvalidApiRequestError unless accept_header.valid?

  request.subdomains.first == 'api' &&
  requested_version        == version_constraint
end