Uses repository pattern to fetch ShopifyAPI::Session

Also implemented a simple in memory storage adapter that associates the ShopifyAPI::Session with a UUID. It's not really a solution for production environments but does provide a starting point. Basically what you want is a really thin adapter that makes it easy to pull the associated sessions from your database.

If you are using ActiveRecord, the only method you'd need to implement is store on the relevant Shop model for your application

Please review @maartenvg @mtaher @jeromecornet for the code and stuff
Please provide a security review @HoLyVieR just to be sure I'm not being a goof anywhere

This is an improvement based on a conversation with @davefp and seeing Pull Request #90 by @choonkeat

Fixes #85 
yarp.


On 10 June 2014 04:41, danielristic <notifications@github.com> wrote:

> In
> lib/generators/shopify_app/templates/config/initializers/shopify_session_repository.rb:
>
> > @@ -0,0 +1,21 @@
> > +# You should replace InMemorySessionStore with what you will be using
> > +# in Production
> > +#
> > +# Interface to implement are self.retrieve(id) and self.store(ShopifyAPI::Session)
> > +#
> > +# Here is how you would add these functions to an ActiveRecord:
> > +#
> > +# class Shop < ActiveRecord::Base
> > +#   def self.store(session)
> > +#     shop = Shop.new(domain: session.url, token: session.token)
> > +#     shop.save!
> > +#     shop.id
> > +#   end
> > +#
> > +#   def retrieve(id)
>
> Should not it be def self.retrieve(id)?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/Shopify/shopify_app/pull/92/files#r13582778>.
>



-- 
Chris Saunders // Developer @ Shopify