Class: RoutingFilter::ForceExtension
- Defined in:
- lib/routing_filter/force_extension.rb
Instance Attribute Summary collapse
-
#exclude ⇒ Object
readonly
Returns the value of attribute exclude.
-
#extension ⇒ Object
readonly
Returns the value of attribute extension.
Attributes inherited from Base
Instance Method Summary collapse
- #around_generate(*args, &block) ⇒ Object
- #around_recognize(path, env) {|path, env| ... } ⇒ Object
-
#initialize(*args) ⇒ ForceExtension
constructor
A new instance of ForceExtension.
Methods inherited from Base
#predecessor, #run, #run_reverse, #successor
Constructor Details
#initialize(*args) ⇒ ForceExtension
Returns a new instance of ForceExtension.
7 8 9 10 11 |
# File 'lib/routing_filter/force_extension.rb', line 7 def initialize(*args) super @extension ||= 'html' @exclude = %r(^(http.?://[^/]+)?\/?$) if @exclude.nil? end |
Instance Attribute Details
#exclude ⇒ Object (readonly)
Returns the value of attribute exclude.
5 6 7 |
# File 'lib/routing_filter/force_extension.rb', line 5 def exclude @exclude end |
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
5 6 7 |
# File 'lib/routing_filter/force_extension.rb', line 5 def extension @extension end |
Instance Method Details
#around_generate(*args, &block) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/routing_filter/force_extension.rb', line 18 def around_generate(*args, &block) returning yield do |result| url = result.is_a?(Array) ? result.first : result append_extension!(url) if append_extension?(url) end end |
#around_recognize(path, env) {|path, env| ... } ⇒ Object
13 14 15 16 |
# File 'lib/routing_filter/force_extension.rb', line 13 def around_recognize(path, env, &block) extract_extension!(path) unless excluded?(path) yield(path, env) end |