Module: Footnotes::Extensions::Routes

Defined in:
lib/rails-footnotes/notes/routes_note.rb

Instance Method Summary collapse

Instance Method Details

#filtered_routes(filter = {}) ⇒ Object

Filter routes according to the filter sent



45
46
47
48
49
50
51
52
# File 'lib/rails-footnotes/notes/routes_note.rb', line 45

def filtered_routes(filter = {})
  return [] unless filter.is_a?(Hash)
  return routes.reject do |r| 
    filter_diff = filter.diff(r.requirements)
    route_diff  = r.requirements.diff(filter)
    (filter_diff == filter) || (filter_diff != route_diff)
  end
end