Created
July 28, 2010 05:10
-
-
Save deepfryed/493448 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/ruby | |
class Flash < Hash | |
class List < Array | |
def to_s | |
map {|v| "<li>#{v}</li>" }.join('') | |
end | |
end | |
def []= k, v | |
super(k, List.new(fetch(k, []) + [v])) | |
end | |
end | |
flash = Flash.new {|h,k| h[k] = Flash::List.new } | |
flash[:success] = "This worked" | |
flash[:success] = "This worked too!" | |
puts flash[:success] | |
puts flash[:success].to_s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment