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, &block) ⇒ 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.
20 21 22 23 24 |
# File 'lib/routing_filter/filters/extension.rb', line 20 def initialize(*args) super @exclude = [:exclude] @extension = [:extension] || 'html' end |
Instance Attribute Details
#exclude ⇒ Object (readonly)
Returns the value of attribute exclude.
18 19 20 |
# File 'lib/routing_filter/filters/extension.rb', line 18 def exclude @exclude end |
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
18 19 20 |
# File 'lib/routing_filter/filters/extension.rb', line 18 def extension @extension end |
Instance Method Details
#around_generate(params, &block) ⇒ Object
31 32 33 34 35 |
# File 'lib/routing_filter/filters/extension.rb', line 31 def around_generate(params, &block) yield.tap do |result| result.update append_extension!(result.url) if append_extension?(result.url) end end |
#around_recognize(path, env, &block) ⇒ Object
26 27 28 29 |
# File 'lib/routing_filter/filters/extension.rb', line 26 def around_recognize(path, env, &block) extract_extension!(path) unless excluded?(path) yield end |