{"action":"created","issue":{"url":"https://api.github.com/repos/rom-rb/rom/issues/155","labels_url":"https://api.github.com/repos/rom-rb/rom/issues/155/labels{/name}","comments_url":"https://api.github.com/repos/rom-rb/rom/issues/155/comments","events_url":"https://api.github.com/repos/rom-rb/rom/issues/155/events","html_url":"https://github.com/rom-rb/rom/pull/155","id":57693061,"number":155,"title":"Add Relation::Loaded and use it in rom.relation {}","user":{"login":"solnic","id":1066,"avatar_url":"https://avatars.githubusercontent.com/u/1066?v=3","gravatar_id":"","url":"https://api.github.com/users/solnic","html_url":"https://github.com/solnic","followers_url":"https://api.github.com/users/solnic/followers","following_url":"https://api.github.com/users/solnic/following{/other_user}","gists_url":"https://api.github.com/users/solnic/gists{/gist_id}","starred_url":"https://api.github.com/users/solnic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solnic/subscriptions","organizations_url":"https://api.github.com/users/solnic/orgs","repos_url":"https://api.github.com/users/solnic/repos","events_url":"https://api.github.com/users/solnic/events{/privacy}","received_events_url":"https://api.github.com/users/solnic/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2015-02-14T13:30:48Z","updated_at":"2015-02-19T15:59:27Z","closed_at":"2015-02-18T10:56:46Z","pull_request":{"url":"https://api.github.com/repos/rom-rb/rom/pulls/155","html_url":"https://github.com/rom-rb/rom/pull/155","diff_url":"https://github.com/rom-rb/rom/pull/155.diff","patch_url":"https://github.com/rom-rb/rom/pull/155.patch"},"body":"This does a couple of things:\r\n\r\n- adds `ROM::Env#relation` that yields *relation object* to the block and returns an instance of `Relation::Loaded` it means that you have access to all methods exposed by a relation there including adapter-specific query DSL\r\n- `Relation::Loaded` exposes `#map_with` interface that accepts name of a mapper that should be used\r\n- `Relation::Loaded#map_with` supports multiple mapper names so we can map and decorate tuples passing them through a \"mapping pipe\", see my comment with an example in this PR\r\n- the contract is that `map_with` can be called only once, it returns an array\r\n- `ROM::Env#mappers` returns a registry of relation mappers that were defined during setup\r\n\r\nThings to consider:\r\n\r\n- Deprecate usage of Reader and remove it in 0.7.0 (or 1.0.0!) - I realized this is a very heavy abstraction and even though I still want to maintain the logic of restricting access to relation only to methods defined by me and avoid using query dsls I no longer think rom core is the right place to put it\r\n- Extend Mapper API with composability so that we can \"join\" mappers as a nice lower-level API and re-use it in `Relation::Loaded`"},"comment":{"url":"https://api.github.com/repos/rom-rb/rom/issues/comments/75077326","html_url":"https://github.com/rom-rb/rom/pull/155#issuecomment-75077326","issue_url":"https://api.github.com/repos/rom-rb/rom/issues/155","id":75077326,"user":{"login":"solnic","id":1066,"avatar_url":"https://avatars.githubusercontent.com/u/1066?v=3","gravatar_id":"","url":"https://api.github.com/users/solnic","html_url":"https://github.com/solnic","followers_url":"https://api.github.com/users/solnic/followers","following_url":"https://api.github.com/users/solnic/following{/other_user}","gists_url":"https://api.github.com/users/solnic/gists{/gist_id}","starred_url":"https://api.github.com/users/solnic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solnic/subscriptions","organizations_url":"https://api.github.com/users/solnic/orgs","repos_url":"https://api.github.com/users/solnic/repos","events_url":"https://api.github.com/users/solnic/events{/privacy}","received_events_url":"https://api.github.com/users/solnic/received_events","type":"User","site_admin":false},"created_at":"2015-02-19T15:59:27Z","updated_at":"2015-02-19T15:59:27Z","body":"With some conventions in place we could configure entire environment from a minimum set of classes. As I mentioned that's doable and will be done at some point in the future. Right now we need to explicitly define mapper classes.\r\n\r\nRe `SimpleDelegator` it's a class from ruby stdlib."}}