Module: Rack::Mount::Route::Base
- Included in:
- Rack::Mount::Route
- Defined in:
- lib/rack/mount/route.rb
Overview
:nodoc:
Constant Summary collapse
- VALID_CONDITIONS =
TODO: Support any method on Request object
[:method, :path].freeze
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#throw ⇒ Object
writeonly
Sets the attribute throw.
Instance Method Summary collapse
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
8 9 10 |
# File 'lib/rack/mount/route.rb', line 8 def app @app end |
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
8 9 10 |
# File 'lib/rack/mount/route.rb', line 8 def conditions @conditions end |
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
8 9 10 |
# File 'lib/rack/mount/route.rb', line 8 def defaults @defaults end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
9 10 11 |
# File 'lib/rack/mount/route.rb', line 9 def method @method end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/rack/mount/route.rb', line 8 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/rack/mount/route.rb', line 9 def path @path end |
#throw=(value) ⇒ Object (writeonly)
Sets the attribute throw
10 11 12 |
# File 'lib/rack/mount/route.rb', line 10 def throw=(value) @throw = value end |
Instance Method Details
#initialize(app, conditions, defaults, name) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rack/mount/route.rb', line 12 def initialize(app, conditions, defaults, name) @app = app validate_app! @throw = Const::NOT_FOUND_RESPONSE @name = name.to_sym if name @defaults = (defaults || {}).freeze @conditions = conditions validate_conditions! method = @conditions.delete(:method) @method = method.to_s.upcase if method path = @conditions.delete(:path) if path.is_a?(Regexp) @path = RegexpWithNamedGroups.new(path) elsif path.is_a?(String) path = "/#{path}" unless path =~ /^\// @path = RegexpWithNamedGroups.compile("^#{path}$") end @path.freeze @conditions.freeze end |