module CachedRoutes::RouteSet

Public Class Methods

included(base) click to toggle source
# File lib/cached_routes/route_set.rb, line 4
def self.included(base)
  base.alias_method_chain :draw, :caching
end

Public Instance Methods

draw_with_caching(*args, &block) click to toggle source
# File lib/cached_routes/route_set.rb, line 8
def draw_with_caching(*args, &block)
  marshaller = Marshaller.new
  if marshaller.can_unmarshal_routes?
    marshaller.unmarshal_routes(self.set.routes, self.named_routes)
  else
    routes_before = self.set.routes.clone
    draw_without_caching(*args, &block)
    marshaller.marshal_routes(self.set.routes - routes_before)
  end
end