Skip to content

Instantly share code, notes, and snippets.

@sidonath
Last active August 29, 2015 13:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidonath/10450111 to your computer and use it in GitHub Desktop.
Save sidonath/10450111 to your computer and use it in GitHub Desktop.
# register services
Application.register :session do
SessionStore.new(store: Application.lookup(:database_store))
end
Application.register :database_store do
# code to initialize database storage for session
end
# inject session service into every action
Application.inject('action', :session)
class Show
include Lotus::Action
before :authenticate
def initialize(repository = Article)
@repository = repository
end
def call(params)
@article = @repository.find params[:id]
end
private
def authenticate
throw 401 unless session[:user_id]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment