Class: RoutingFilter::Extension

Inherits:
Filter
  • Object
show all
Defined in:
lib/routing_filter/filters/extension.rb

Instance Attribute Summary collapse

Attributes inherited from Filter

#next, #options, #previous

Instance Method Summary collapse

Methods inherited from Filter

#run, #run_reverse

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   = options[:exclude]
  @extension = options[:extension] || 'html'
end

Instance Attribute Details

#excludeObject (readonly)

Returns the value of attribute exclude.



24
25
26
# File 'lib/routing_filter/filters/extension.rb', line 24

def exclude
  @exclude
end

#extensionObject (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

Yields:

  • (path, env)


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