Created
December 12, 2011 21:53
-
-
Save stevenharman/1469293 to your computer and use it in GitHub Desktop.
A simple wrapper over Hash to providing a way to override a default convention.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PageName | |
| @pages = { | |
| "Super Awesome Page" => "bad-ass-page-name-2", | |
| "Secret Page" => :secret_page_as_symbol | |
| } | |
| def self.[](name) | |
| @pages.fetch(name) { |n| n.gsub(/\s/, '') } | |
| end | |
| end | |
| # Usage: PageName['Hello Steve'] #=> "HelloSteve" | |
| # PageName['Super Awesome Page'] #=> "bad-ass-page-name-2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment