Skip to content

Instantly share code, notes, and snippets.

@hubertlepicki
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hubertlepicki/9564569 to your computer and use it in GitHub Desktop.
Save hubertlepicki/9564569 to your computer and use it in GitHub Desktop.
The @app Object
class ApplicationController < ActionController::Base
...
def intranet
@intranet ||= Intranet.for_employee(current_user)
end
helper_method :intranet
end
class Intranet
...
def files(manager_source = FileManager.method(:new),
browser_source = FileBrowser.method(:new))
@files ||= if admin?
manager_source.call
else
browser_source.call
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment