sinatra-named-routes-subdomains 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,12 @@ module Sinatra
10
10
  # Extended support passing in named route and parameters.
11
11
  def uri( addr = nil, absolute = true, params = nil )
12
12
  if addr.is_a? Symbol
13
+ if !params.nil?
14
+ params = params.merge( NamedRoutes.get_params( addr ) )
15
+ else
16
+ params = NamedRoutes.get_params( addr )
17
+ end
18
+
13
19
  addr = NamedRoutes.get_path( addr, params )
14
20
  end
15
21
 
@@ -61,6 +67,11 @@ module Sinatra
61
67
  NamedRoutes.routes[name].build params
62
68
  end
63
69
 
70
+ def self.get_params(name)
71
+ raise ArgumentError, "No route with the name #{name} exists." if NamedRoutes.routes.nil?
72
+ NamedRoutes.routes[name].params
73
+ end
74
+
64
75
  def self.routes
65
76
  @@routes ||= {}
66
77
  end
@@ -2,6 +2,7 @@ module Sinatra
2
2
  module NamedRoutes
3
3
  class Route
4
4
  attr_reader :source
5
+ attr_reader :params
5
6
 
6
7
  def initialize(route, params = {})
7
8
  route = route.source if route.is_a? Regexp
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module BlueRoutes
3
- VERSION = '0.1.5'
3
+ VERSION = '0.1.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-named-routes-subdomains
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: