Class: MVCLI::Router::Route

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

Instance Method Summary collapse

Constructor Details

#initialize(router, pattern, action, options = {}) ⇒ Route

Returns a new instance of Route.



65
66
67
68
# File 'lib/mvcli/router.rb', line 65

def initialize(router, pattern, action, options = {})
  @pattern = Pattern.new pattern.to_s
  @router, @action, @options = router, action, options
end

Instance Method Details

#match(argv) ⇒ Object



70
71
72
73
74
75
76
# File 'lib/mvcli/router.rb', line 70

def match(argv)
  argv = MVCLI::Argv.new argv
  match = @pattern.match(argv.arguments)
  if match.matches?
    @router.actions.new match, @action
  end
end