Class: RoutingFilter::Categories

Inherits:
Filter
  • Object
show all
Defined in:
lib/adva/routing_filters/categories.rb

Instance Method Summary collapse

Instance Method Details

#around_generate(params, &block) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/adva/routing_filters/categories.rb', line 23

def around_generate(params, &block)
  category_id = params.delete('category_id') || params.delete(:category_id)
  yield.tap do |path|
    # p "#{self.class.name}: #{path}"
    insert_category_path(path, category_id) if !excluded?(path) && category_id
  end
end

#around_recognize(path, env, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/adva/routing_filters/categories.rb', line 11

def around_recognize(path, env, &block)
  # p "#{self.class.name}: #{path}"
  unless excluded?(path)
    category_id = extract_category_id(env, path)
    yield.tap do |params|
      params[:category_id] = category_id if category_id
    end
  else
    yield
  end
end