Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #85 manipulate session[:shopify] as YAML #90

Closed
wants to merge 1 commit into from

Conversation

choonkeat
Copy link

instead of as ShopifyAPI::Session object (which session cannot handle properly)

@csaunders
Copy link
Contributor

This isn't a great solution. Instead of storing the entire session we should be coming up with a better way of patching this.

I was thinking that just having a shops table would work though that does add the requirement for a database to be required in order to just play with the app. Alternatively could use something like a ShopsRepository that does something like stores the information in a global variable or something.

This in-memory approach wouldn't really work for a production setup but you could switch out the repo backend to just be active record.

session[:id] = ShopsRepo.store(shopify_session)
# 17def012-9d4a-4982-8d04-87abe379dadd

shopify_session = ShopsRepo.fetch(session[:id])

class ShopsRepo
  def self.store(session)
    id = SecureRandom.uuid
    repo[id] = {token: session.token, url: session.url} # or simply repo[id] = session
    id
  end

  def self.fetch(id)
    if data = repo[id]
      ShopifyAPI::Session.new(token: data[:token], url: data[:url])
    end
  end

  def self.repo
    @@repo ||= {}
  end
end

@csaunders
Copy link
Contributor

See #92

@csaunders csaunders closed this Jun 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants