Class: Confinement::RouteIdentifiers
- Inherits:
-
Object
- Object
- Confinement::RouteIdentifiers
- Defined in:
- lib/confinement.rb
Overview
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.
Instance Method Summary collapse
- #[](route) ⇒ Object
- #[]=(route, content) ⇒ Object
- #done! ⇒ Object
-
#initialize ⇒ RouteIdentifiers
constructor
A new instance of RouteIdentifiers.
Constructor Details
#initialize ⇒ RouteIdentifiers
Returns a new instance of RouteIdentifiers.
308 309 310 |
# File 'lib/confinement.rb', line 308 def initialize self.lookup = {} end |
Instance Method Details
#[](route) ⇒ Object
316 317 318 319 320 321 322 323 324 |
# 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) ⇒ Object
326 327 328 329 330 331 332 333 334 335 336 337 338 |
# 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! ⇒ Object
312 313 314 |
# File 'lib/confinement.rb', line 312 def done! @done = true end |