tannerburson / multi-sinatra-sample

Sample application showing how to use multiple sinatra subclass applications in a single process.
44 stars 4 forks source link

Sharing data #1

Open jlebrech opened 11 years ago

jlebrech commented 11 years ago

Do main and blog share data?

For example if I have a login app and a blog app, could I get the blog app to find the current_user from login app?

tannerburson commented 11 years ago

If you define current_user as an attribute or instance method of LoginApp, then you couldn't do that easily. You could define it as a method on your wrapping module, or even create a singleton class outside the scope of either of your Sinatra subclasses to track it. You could also create a class level method on LoginApp, and then call LoginApp.current_user from your BlogApp to get access to the information. Obviously none of these are straightforward solutions, but it's certainly possible.