Skip to content

Instantly share code, notes, and snippets.

@deepfryed
Created July 28, 2010 05:10
Show Gist options
  • Save deepfryed/493448 to your computer and use it in GitHub Desktop.
Save deepfryed/493448 to your computer and use it in GitHub Desktop.
#!/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