Class: Praxis::Router::VersionMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(target, version: 'n/a') ⇒ VersionMatcher

Returns a new instance of VersionMatcher.



10
11
12
13
# File 'lib/praxis/router.rb', line 10

def initialize(target, version: 'n/a')
  @target = target
  @version = version
end

Instance Method Details

#call(request) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/praxis/router.rb', line 15

def call(request)
  if request.version == @version
    @target.call(request)
  else
    # Version doesn't match, pass and continue
    request.unmatched_versions << @version
    throw :pass
  end
end