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.



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

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

Instance Method Details

#call(request) ⇒ Object



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

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