class Confinement::RouteIdentifiers

RouteIdentifiers is called such because it doesn't hold the actual content's route. The content's own `url_path` does.

This is mainly so that assets could be referenced internally with a static identifier even though it could have a hashed route.

Attributes

lookup[RW]

Public Class Methods

new() click to toggle source
# File lib/confinement.rb, line 308
def initialize
  self.lookup = {}
end

Public Instance Methods

[](route) click to toggle source
# File lib/confinement.rb, line 316
def [](route)
  route = route.normalize_for_route

  if !lookup.key?(route)
    raise "Route is not defined"
  end

  self.lookup[route]
end
[]=(route, content) click to toggle source
# File lib/confinement.rb, line 326
def []=(route, content)
  raise "Can't add more routes after initial setup" if @done

  route = route.normalize_for_route

  if lookup.key?(route)
    raise "Route already defined!"
  end

  content.url_path = route

  lookup[route] = content
end
done!() click to toggle source
# File lib/confinement.rb, line 312
def done!
  @done = true
end