class Phenotype::PathStrategy

Attributes

version_pattern[R]

Public Class Methods

new(version_pattern = Regexp.new('^\/v(\d+)\/?')) click to toggle source
# File lib/phenotype/strategies/path_strategy.rb, line 7
def initialize(version_pattern = Regexp.new('^\/v(\d+)\/?'))
  @version_pattern = version_pattern
end

Public Instance Methods

version(env) click to toggle source
# File lib/phenotype/strategies/path_strategy.rb, line 11
def version(env)
  match = Rack::Request.new(env).path.match(version_pattern)
  match && match[1] || NullStrategy.new
end