Skip to content
This repository has been archived by the owner on Aug 25, 2020. It is now read-only.

Extract different environments (Sinatra, Rails, ... ) #40

Open
mulderp opened this issue Apr 10, 2013 · 6 comments
Open

Extract different environments (Sinatra, Rails, ... ) #40

mulderp opened this issue Apr 10, 2013 · 6 comments

Comments

@mulderp
Copy link
Contributor

mulderp commented Apr 10, 2013

In order to make integration of different ORM setups easier (ActiveRecord, ActiveModel, Redis, .. ), a first step might be to separate the environments for Sinatra and Rails.

I did a first preparation in my fork here: https://github.com/mulderp/rack-oauth2-server/tree/extract_envs

This is a strategy that I saw here too: https://github.com/jodosha/redis-store

What do you think? This would most probably evolve into different gems too.

@mulderp
Copy link
Contributor Author

mulderp commented Apr 10, 2013

The names of the Gems might become:

  • oauth2-sinatra
  • oauth2-active_record
  • oauth2-active_model

etc.

@bploetz
Copy link
Collaborator

bploetz commented Apr 10, 2013

rack-oauth2-server is rack middleware, so it works with any Rack-compliant framework (Rails, Sinatra, etc). What would be in oauth2-sinatra that's not in oauth2-active_record? (Also, ActiveRecord is an implementation of ActiveModel for relational databases, so not sure you need a distinction between the two).

Regardless, if what you're really going for is to make the gem persistence agnostic (and not just hard-wired to MongoDB), you should explore introducing the Repository pattern instead.

http://blog.8thlight.com/mike-ebert/2013/03/23/the-repository-pattern.html

Then you can have Repository implementations for various data stores, either as separate gems, or available in rack-oauth2-server itself, and you simply configure which persistence store you want to use.

My two cents....

@mulderp
Copy link
Contributor Author

mulderp commented Apr 11, 2013

Thanks Brian! The article on the repository pattern looks very helpful indeed.

About the extraction issue, my feeling was that some boilerplate could be removed when working in separate projects (i.e. Sinatra does not need Rails and vice-versa). Maybe it is just that I am new to the codebase that I don't see a simpler way to test the actual Rack middleware vs. the framework boilerplate (which are more integration tests, and maybe some extraction of the test there could help in getting closer to working at an ORM adapter)

@mulderp
Copy link
Contributor Author

mulderp commented Apr 11, 2013

I discovered:

https://github.com/trumant/rack-oauth2-server-active-record/commits/active_record

That looks like having a separate sub-repo for AR interesting, but I need to experiment to understand better.

@mulderp
Copy link
Contributor Author

mulderp commented Apr 12, 2013

Hm.. this looks like an interesting plugin for Rack too to handle storage of tokens: https://github.com/minad/moneta

@assaf
Copy link
Owner

assaf commented Apr 13, 2013

Moneta looks really interesting

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants