Skip to content

Instantly share code, notes, and snippets.

@MSch
Created November 13, 2010 11:16
Show Gist options
  • Select an option

  • Save MSch/675253 to your computer and use it in GitHub Desktop.

Select an option

Save MSch/675253 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
def session
@session_wrapper ||= SessionWrapper.new(request.session)
end
end
class SessionWrapper < SimpleDelegator
def initialize(session)
super(session)
@session = session
end
def mergable_users
@session['mergable_users'] ||= Set.new
end
end
@MSch
Copy link
Author

MSch commented Nov 13, 2010

Instead of always writing

(session['mergable_users']||=Set.new) << 123

I can now write

session.mergable_users << 123

and it will work just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment