Class: RoutingFilter::Extension
- Defined in:
- lib/routing_filter/filters/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 Filter
Instance Method Summary collapse
- #around_generate(params, &block) ⇒ Object
- #around_recognize(path, env) {|path, env| ... } ⇒ Object
-
#initialize(*args) ⇒ Extension
constructor
A new instance of Extension.
Methods inherited from Filter
Constructor Details
#initialize(*args) ⇒ Extension
Returns a new instance of Extension.
26 27 28 29 30 |
# File 'lib/routing_filter/filters/extension.rb', line 26 def initialize(*args) super @exclude = [:exclude] @extension = [:extension] || 'html' end |
Instance Attribute Details
#exclude ⇒ Object (readonly)
Returns the value of attribute exclude.
24 25 26 |
# File 'lib/routing_filter/filters/extension.rb', line 24 def exclude @exclude end |
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
24 25 26 |
# File 'lib/routing_filter/filters/extension.rb', line 24 def extension @extension end |
Instance Method Details
#around_generate(params, &block) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/routing_filter/filters/extension.rb', line 37 def around_generate(params, &block) yield.tap 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
32 33 34 35 |
# File 'lib/routing_filter/filters/extension.rb', line 32 def around_recognize(path, env, &block) extract_extension!(path) unless excluded?(path) yield(path, env) end |