DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Ruby: Extending Mechanize's Cookie Methods

06.20.2009
| 3800 views |
  • submit to reddit
        The included Methods only allow saving and loading to Files, but sometimes it is more useful to load/save it from a String:

class WWW::Mechanize::CookieJar
  public
  def save_str
    return URI.escape(YAML::dump(@jar))
  end

  def load_str(str)
    @jar = YAML::load(URI.unescape(str))
  end
end