class AuPair::ApiConstraint
Attributes
numeric_version[RW]
path_part[RW]
Public Class Methods
new(path_part)
click to toggle source
# File lib/au_pair/api_constraint.rb, line 5 def initialize(path_part) @path_part = path_part.downcase @numeric_version = path_part.gsub(/.?([0-9]+)/, "\\1").to_i end
Public Instance Methods
header_matches?(request)
click to toggle source
# File lib/au_pair/api_constraint.rb, line 18 def header_matches?(request) request.headers['x-api-version'] =~ /^[^\d]*#{numeric_version}$/ end
matches?(request)
click to toggle source
# File lib/au_pair/api_constraint.rb, line 10 def matches?(request) path_matches?(request) || header_matches?(request) || param_matches?(request) end
param_matches?(request)
click to toggle source
# File lib/au_pair/api_constraint.rb, line 22 def param_matches?(request) request.request_parameters["api_version"].to_i == numeric_version || request.query_parameters["api_version"].to_i == numeric_version end
path_matches?(request)
click to toggle source
# File lib/au_pair/api_constraint.rb, line 14 def path_matches?(request) request.path =~ /\/#{@path_part}\//i end