Class: Makanai::Router::Route

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

Constant Summary collapse

DYNAMIC_PREFIX =

Prefix for dynamic path

':'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, process:, method:) ⇒ Route

Returns a new instance of Route.



41
42
43
44
45
46
# File 'lib/makanai/router.rb', line 41

def initialize(path:, process:, method:)
  @path = path
  @process = process
  @method = method
  @url_args = {}
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



48
49
50
# File 'lib/makanai/router.rb', line 48

def method
  @method
end

#pathObject (readonly)

Returns the value of attribute path.



48
49
50
# File 'lib/makanai/router.rb', line 48

def path
  @path
end

#processObject (readonly)

Returns the value of attribute process.



48
49
50
# File 'lib/makanai/router.rb', line 48

def process
  @process
end

#url_argsObject (readonly)

Returns the value of attribute url_args.



48
49
50
# File 'lib/makanai/router.rb', line 48

def url_args
  @url_args
end

Instance Method Details

#match?(path:, method:) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
53
# File 'lib/makanai/router.rb', line 50

def match?(path:, method:)
  build_url_args(path: path)
  path_match?(path) && self.method == method
end