{"action":"created","comment":{"url":"https://api.github.com/repos/Shopify/shopify_app/pulls/comments/43764526","id":43764526,"diff_hunk":"@@ -111,47 +111,9 @@ end\n ShopifyApp::SessionRepository\n -----------------------------\n \n-`ShopifyApp::SessionRepository` allows you as a developer to define how your sessions are retrieved and\n-stored for a shop. This can simply be your `Shop` model that stores the API Token and shop name. If\n-you are using ActiveRecord, then all you need to implement is `self.store(shopify_session)` and\n-`self.retrieve(id)` in order to store the record on disk or retrieve it for use at a later point.\n-It is imperative that your store method returns the identifier for the session. Typically this is\n-just the record ID.\n-\n-Your ActiveRecord model would look something like this:\n-\n-```ruby\n-class Shop < ActiveRecord::Base\n-  def self.store(session)\n-    shop = self.new(domain: session.url, token: session.token)\n-    shop.save!\n-    shop.id\n-  end\n-\n-  def self.retrieve(id)\n-    if shop = self.where(id: id).first\n-      ShopifyAPI::Session.new(shop.domain, shop.token)\n-    end\n-  end\n-end\n-```\n-\n-By default you will have an in memory store but it **won't work** on multi-server environments since\n-they won't be sharing the static data that would be required in case your user gets directed to a\n-different server by your load balancer.\n-\n-The in memory store also does not behave well on Heroku because the session data would be destroyed\n-when a dyno is killed due to inactivity.\n-\n-Changing the `ShopifyApp::SessionRepository.storage` can simply be done by editing\n-`config/initializers/shopify_session_repository.rb` to use the correct model.\n-\n-```ruby\n-ShopifyApp::SessionRepository.storage = 'Shop'\n-```\n-\n-If you run the `shop_model` generator it will create the required code to use the generated Shop model as the SessionRepository and update the initializer.\n+`ShopifyApp::SessionRepository` allows you as a developer to define how your sessions are retrieved and stored for a shop. The `SessionRepository` is configured using the `config/initializers/shopify_session_repository.rb` file and can be set to any object the implements `self.store(shopify_session)` which stores the session and returns a unique identifier and `self.retrieve(id)` which returns a `ShopifyAPI::Session` for the passed id. See either the `InMemorySessionStore` or the `SessionStorage` module for examples.","path":"README.md","position":44,"original_position":44,"commit_id":"d5917d4470bd7881e3e92b46d64fbbb4ec15e9d1","original_commit_id":"d5917d4470bd7881e3e92b46d64fbbb4ec15e9d1","user":{"login":"stephenminded","id":76227,"avatar_url":"https://avatars.githubusercontent.com/u/76227?v=3","gravatar_id":"","url":"https://api.github.com/users/stephenminded","html_url":"https://github.com/stephenminded","followers_url":"https://api.github.com/users/stephenminded/followers","following_url":"https://api.github.com/users/stephenminded/following{/other_user}","gists_url":"https://api.github.com/users/stephenminded/gists{/gist_id}","starred_url":"https://api.github.com/users/stephenminded/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephenminded/subscriptions","organizations_url":"https://api.github.com/users/stephenminded/orgs","repos_url":"https://api.github.com/users/stephenminded/repos","events_url":"https://api.github.com/users/stephenminded/events{/privacy}","received_events_url":"https://api.github.com/users/stephenminded/received_events","type":"User","site_admin":false},"body":":+1: ","created_at":"2015-11-03T15:51:31Z","updated_at":"2015-11-03T15:51:31Z","html_url":"https://github.com/Shopify/shopify_app/pull/173#discussion_r43764526","pull_request_url":"https://api.github.com/repos/Shopify/shopify_app/pulls/173","_links":{"self":{"href":"https://api.github.com/repos/Shopify/shopify_app/pulls/comments/43764526"},"html":{"href":"https://github.com/Shopify/shopify_app/pull/173#discussion_r43764526"},"pull_request":{"href":"https://api.github.com/repos/Shopify/shopify_app/pulls/173"}}},"pull_request":{"url":"https://api.github.com/repos/Shopify/shopify_app/pulls/173","id":49455258,"html_url":"https://github.com/Shopify/shopify_app/pull/173","diff_url":"https://github.com/Shopify/shopify_app/pull/173.diff","patch_url":"https://github.com/Shopify/shopify_app/pull/173.patch","issue_url":"https://api.github.com/repos/Shopify/shopify_app/issues/173","number":173,"state":"open","locked":false,"title":"move SessionStorage from a generated class to a re-usable module","user":{"login":"kevinhughes27","id":1965489,"avatar_url":"https://avatars.githubusercontent.com/u/1965489?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinhughes27","html_url":"https://github.com/kevinhughes27","followers_url":"https://api.github.com/users/kevinhughes27/followers","following_url":"https://api.github.com/users/kevinhughes27/following{/other_user}","gists_url":"https://api.github.com/users/kevinhughes27/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinhughes27/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinhughes27/subscriptions","organizations_url":"https://api.github.com/users/kevinhughes27/orgs","repos_url":"https://api.github.com/users/kevinhughes27/repos","events_url":"https://api.github.com/users/kevinhughes27/events{/privacy}","received_events_url":"https://api.github.com/users/kevinhughes27/received_events","type":"User","site_admin":false},"body":"The generated `SessionStorage` class was an un-needed extra bit of mis-direction surrounding the `SessionRepository` object which allows you to tell ShopifyApp how to retrieve your session. It used to look like this:\r\n\r\nSessionRepository -> SessionStorage -> Shop\r\n\r\nSessionStorage just looked up and returned a shop. With this done as a mixin users can include in whichever model includes the `shopify_domain` and `shopify_token` or then can write their own `store` and `retrieve` on a class of their choosing just like before. The flow now looks like this:\r\n\r\nSessionRepository -> Shop\r\n\r\nAnd shop includes the SessionStorage module.\r\n\r\nAnother bonus of this cleanup is it results in less generated code and more code that is part of the gem meaning this gem feels less invasive to the host rails application.\r\n\r\nfor review\r\n@christinejordan @christhomson ","created_at":"2015-11-02T16:47:12Z","updated_at":"2015-11-03T15:51:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"971dcf13644ef8a8a627acdf3af92f6f5fc2e5bf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Shopify/shopify_app/pulls/173/commits","review_comments_url":"https://api.github.com/repos/Shopify/shopify_app/pulls/173/comments","review_comment_url":"https://api.github.com/repos/Shopify/shopify_app/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Shopify/shopify_app/issues/173/comments","statuses_url":"https://api.github.com/repos/Shopify/shopify_app/statuses/d5917d4470bd7881e3e92b46d64fbbb4ec15e9d1","head":{"label":"Shopify:session_store_module","ref":"session_store_module","sha":"d5917d4470bd7881e3e92b46d64fbbb4ec15e9d1","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":61203,"name":"shopify_app","full_name":"Shopify/shopify_app","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/shopify_app","description":"Adds a full Shopify API Application environment to your application","fork":false,"url":"https://api.github.com/repos/Shopify/shopify_app","forks_url":"https://api.github.com/repos/Shopify/shopify_app/forks","keys_url":"https://api.github.com/repos/Shopify/shopify_app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/shopify_app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/shopify_app/teams","hooks_url":"https://api.github.com/repos/Shopify/shopify_app/hooks","issue_events_url":"https://api.github.com/repos/Shopify/shopify_app/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/shopify_app/events","assignees_url":"https://api.github.com/repos/Shopify/shopify_app/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/shopify_app/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/shopify_app/tags","blobs_url":"https://api.github.com/repos/Shopify/shopify_app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/shopify_app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/shopify_app/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/shopify_app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/shopify_app/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/shopify_app/languages","stargazers_url":"https://api.github.com/repos/Shopify/shopify_app/stargazers","contributors_url":"https://api.github.com/repos/Shopify/shopify_app/contributors","subscribers_url":"https://api.github.com/repos/Shopify/shopify_app/subscribers","subscription_url":"https://api.github.com/repos/Shopify/shopify_app/subscription","commits_url":"https://api.github.com/repos/Shopify/shopify_app/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/shopify_app/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/shopify_app/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/shopify_app/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/shopify_app/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/shopify_app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/shopify_app/merges","archive_url":"https://api.github.com/repos/Shopify/shopify_app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/shopify_app/downloads","issues_url":"https://api.github.com/repos/Shopify/shopify_app/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/shopify_app/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/shopify_app/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/shopify_app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/shopify_app/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/shopify_app/releases{/id}","created_at":"2008-10-09T15:10:52Z","updated_at":"2015-10-30T14:31:20Z","pushed_at":"2015-11-03T15:43:05Z","git_url":"git://github.com/Shopify/shopify_app.git","ssh_url":"git@github.com:Shopify/shopify_app.git","clone_url":"https://github.com/Shopify/shopify_app.git","svn_url":"https://github.com/Shopify/shopify_app","homepage":"http://shopify.github.io/shopify_app","size":1957,"stargazers_count":339,"watchers_count":339,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":118,"mirror_url":null,"open_issues_count":11,"forks":118,"open_issues":11,"watchers":339,"default_branch":"master"}},"base":{"label":"Shopify:master","ref":"master","sha":"82344669ab23c7509ebc37188e2717afb5ac52c6","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":61203,"name":"shopify_app","full_name":"Shopify/shopify_app","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/shopify_app","description":"Adds a full Shopify API Application environment to your application","fork":false,"url":"https://api.github.com/repos/Shopify/shopify_app","forks_url":"https://api.github.com/repos/Shopify/shopify_app/forks","keys_url":"https://api.github.com/repos/Shopify/shopify_app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/shopify_app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/shopify_app/teams","hooks_url":"https://api.github.com/repos/Shopify/shopify_app/hooks","issue_events_url":"https://api.github.com/repos/Shopify/shopify_app/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/shopify_app/events","assignees_url":"https://api.github.com/repos/Shopify/shopify_app/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/shopify_app/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/shopify_app/tags","blobs_url":"https://api.github.com/repos/Shopify/shopify_app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/shopify_app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/shopify_app/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/shopify_app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/shopify_app/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/shopify_app/languages","stargazers_url":"https://api.github.com/repos/Shopify/shopify_app/stargazers","contributors_url":"https://api.github.com/repos/Shopify/shopify_app/contributors","subscribers_url":"https://api.github.com/repos/Shopify/shopify_app/subscribers","subscription_url":"https://api.github.com/repos/Shopify/shopify_app/subscription","commits_url":"https://api.github.com/repos/Shopify/shopify_app/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/shopify_app/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/shopify_app/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/shopify_app/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/shopify_app/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/shopify_app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/shopify_app/merges","archive_url":"https://api.github.com/repos/Shopify/shopify_app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/shopify_app/downloads","issues_url":"https://api.github.com/repos/Shopify/shopify_app/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/shopify_app/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/shopify_app/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/shopify_app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/shopify_app/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/shopify_app/releases{/id}","created_at":"2008-10-09T15:10:52Z","updated_at":"2015-10-30T14:31:20Z","pushed_at":"2015-11-03T15:43:05Z","git_url":"git://github.com/Shopify/shopify_app.git","ssh_url":"git@github.com:Shopify/shopify_app.git","clone_url":"https://github.com/Shopify/shopify_app.git","svn_url":"https://github.com/Shopify/shopify_app","homepage":"http://shopify.github.io/shopify_app","size":1957,"stargazers_count":339,"watchers_count":339,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":118,"mirror_url":null,"open_issues_count":11,"forks":118,"open_issues":11,"watchers":339,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Shopify/shopify_app/pulls/173"},"html":{"href":"https://github.com/Shopify/shopify_app/pull/173"},"issue":{"href":"https://api.github.com/repos/Shopify/shopify_app/issues/173"},"comments":{"href":"https://api.github.com/repos/Shopify/shopify_app/issues/173/comments"},"review_comments":{"href":"https://api.github.com/repos/Shopify/shopify_app/pulls/173/comments"},"review_comment":{"href":"https://api.github.com/repos/Shopify/shopify_app/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Shopify/shopify_app/pulls/173/commits"},"statuses":{"href":"https://api.github.com/repos/Shopify/shopify_app/statuses/d5917d4470bd7881e3e92b46d64fbbb4ec15e9d1"}}}}