{"action":"created","issue":{"url":"https://api.github.com/repos/CartoDB/cartodb/issues/2775","labels_url":"https://api.github.com/repos/CartoDB/cartodb/issues/2775/labels{/name}","comments_url":"https://api.github.com/repos/CartoDB/cartodb/issues/2775/comments","events_url":"https://api.github.com/repos/CartoDB/cartodb/issues/2775/events","html_url":"https://github.com/CartoDB/cartodb/pull/2775","id":61618529,"number":2775,"title":"2660 extract storage take4 [do NOT merge yet]","user":{"login":"rafatower","id":1914276,"avatar_url":"https://avatars.githubusercontent.com/u/1914276?v=3","gravatar_id":"","url":"https://api.github.com/users/rafatower","html_url":"https://github.com/rafatower","followers_url":"https://api.github.com/users/rafatower/followers","following_url":"https://api.github.com/users/rafatower/following{/other_user}","gists_url":"https://api.github.com/users/rafatower/gists{/gist_id}","starred_url":"https://api.github.com/users/rafatower/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafatower/subscriptions","organizations_url":"https://api.github.com/users/rafatower/orgs","repos_url":"https://api.github.com/users/rafatower/repos","events_url":"https://api.github.com/users/rafatower/events{/privacy}","received_events_url":"https://api.github.com/users/rafatower/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-14T14:27:43Z","updated_at":"2015-03-14T15:06:18Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/CartoDB/cartodb/pulls/2775","html_url":"https://github.com/CartoDB/cartodb/pull/2775","diff_url":"https://github.com/CartoDB/cartodb/pull/2775.diff","patch_url":"https://github.com/CartoDB/cartodb/pull/2775.patch"},"body":"Another version, without access to user_table. `table.user_table.*` is no longer permitted.\r\n\r\nThis was done to avoid exposing functionality of the model through the `Table` service/decorator/façade, as Nacho suggested. Why? I tried two different approaches:\r\n- Keeping the same interface for `Table`. Almost imposible because of the richness of the `Sequel::Model`, `Sequel::Dataset` and related classes.\r\n- Keeping `UserTable` as dumb and ignorant as possible. Not really feasible, cause many business rules are implemented through hooks.\r\n- Exposing `UserTable` functionality directly to client classes. Although it sounded like a good idea at first, this way it is hard to enforce certain business rules (such as setting a table name) without a complex interaction between `Table` and `UserTable`.\r\n\r\nSo finally this is the best design I could come up having something working.\r\n\r\nIf I were to refactor this again, I'd probably take a different approach: do not try to fully isolate the model but extract pieces of functionality little by little and assuming the `Model` would still be the \"director\" of the interactions. Start with value objects and continue with a UserData service or similar.\r\n- Pros: easier and safer to carry on, less radical.\r\n- Cons: harder to get an isolated model, which is bad for porting to ActiveRecord."},"comment":{"url":"https://api.github.com/repos/CartoDB/cartodb/issues/comments/80525498","html_url":"https://github.com/CartoDB/cartodb/pull/2775#issuecomment-80525498","issue_url":"https://api.github.com/repos/CartoDB/cartodb/issues/2775","id":80525498,"user":{"login":"Cartofante","id":5066482,"avatar_url":"https://avatars.githubusercontent.com/u/5066482?v=3","gravatar_id":"","url":"https://api.github.com/users/Cartofante","html_url":"https://github.com/Cartofante","followers_url":"https://api.github.com/users/Cartofante/followers","following_url":"https://api.github.com/users/Cartofante/following{/other_user}","gists_url":"https://api.github.com/users/Cartofante/gists{/gist_id}","starred_url":"https://api.github.com/users/Cartofante/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cartofante/subscriptions","organizations_url":"https://api.github.com/users/Cartofante/orgs","repos_url":"https://api.github.com/users/Cartofante/repos","events_url":"https://api.github.com/users/Cartofante/events{/privacy}","received_events_url":"https://api.github.com/users/Cartofante/received_events","type":"User","site_admin":false},"created_at":"2015-03-14T15:06:18Z","updated_at":"2015-03-14T15:06:18Z","body":"Frontend tests were OK :+1: ([details](http://clinker.cartodb.net/jenkins/job/CartoDB-PR-testing/2353/))"}}