{"action":"created","comment":{"url":"https://api.github.com/repos/QuarkX/Quark/pulls/comments/74546983","id":74546983,"diff_hunk":"@@ -133,3 +133,13 @@ extension Dictionary : MapInitializable {\n         self = this\n     }\n }\n+\n+// MARK: Mappable\n+\n+extension MapInitializable where Self: Mappable {\n+    \n+    public init(map: Map) throws {\n+        try self.init(from: map)\n+    }\n+    ","path":"Sources/Quark/Quark/Core/Map/MapInitializable.swift","position":12,"original_position":12,"commit_id":"af7349371429cd5011e735e8375ff85214059075","original_commit_id":"af7349371429cd5011e735e8375ff85214059075","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Trailing Whitespace Violation: Lines should not have trailing whitespace. (trailing_whitespace)","created_at":"2016-08-12T06:38:25Z","updated_at":"2016-08-12T06:38:25Z","html_url":"https://github.com/QuarkX/Quark/pull/35#discussion_r74546983","pull_request_url":"https://api.github.com/repos/QuarkX/Quark/pulls/35","_links":{"self":{"href":"https://api.github.com/repos/QuarkX/Quark/pulls/comments/74546983"},"html":{"href":"https://github.com/QuarkX/Quark/pull/35#discussion_r74546983"},"pull_request":{"href":"https://api.github.com/repos/QuarkX/Quark/pulls/35"}}},"pull_request":{"url":"https://api.github.com/repos/QuarkX/Quark/pulls/35","id":80961904,"html_url":"https://github.com/QuarkX/Quark/pull/35","diff_url":"https://github.com/QuarkX/Quark/pull/35.diff","patch_url":"https://github.com/QuarkX/Quark/pull/35.patch","issue_url":"https://api.github.com/repos/QuarkX/Quark/issues/35","number":35,"state":"open","locked":false,"title":"Reintroduction of Mapper","user":{"login":"dreymonde","id":17236908,"avatar_url":"https://avatars.githubusercontent.com/u/17236908?v=3","gravatar_id":"","url":"https://api.github.com/users/dreymonde","html_url":"https://github.com/dreymonde","followers_url":"https://api.github.com/users/dreymonde/followers","following_url":"https://api.github.com/users/dreymonde/following{/other_user}","gists_url":"https://api.github.com/users/dreymonde/gists{/gist_id}","starred_url":"https://api.github.com/users/dreymonde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dreymonde/subscriptions","organizations_url":"https://api.github.com/users/dreymonde/orgs","repos_url":"https://api.github.com/users/dreymonde/repos","events_url":"https://api.github.com/users/dreymonde/events{/privacy}","received_events_url":"https://api.github.com/users/dreymonde/received_events","type":"User","site_admin":false},"body":"# Summary\r\n\r\nThis PR introduces new version of `Mapper`. From now on, `Mapper` is not tied with `Map` (former `StructuredData`), but is **generic, lightweight solution** for mapping any kind of «structured data». So by declaring only one initializer for your model, you can map instance of it from any type which conforms to `MapProtocol` (naming is not final). So, new `Mappable` protocol looks like this:\r\n\r\n```swift\r\npublic protocol Mappable {   \r\n    init<Map: MapProtocol>(mapper: Mapper<Map>) throws\r\n}\r\n```\r\n\r\nWhere `MapProtocol` is:\r\n\r\n```swift\r\npublic protocol MapProtocol {\r\n    subscript(indexPath: IndexPathElement) -> Self? { get }\r\n    subscript(indexPath: [IndexPathElement]) -> Self? { get } // has default implementation\r\n    var asArray: [Self]? { get }\r\n    func get<T>() -> T?\r\n}\r\n```\r\n\r\n`Map` and `JSON` conforms to `MapProtocol`.\r\n\r\n`Mapper` can:\r\n- Map «nested» mappables.\r\n- Map arrays.\r\n- Map RawRepresentable enum’s *automatically*.\r\n\r\nMapper also supports the concept of «mapping with context». In situation where you want use `Mapper`, but your layout can *differ* between different formats or sources (for example, you may have `createdAt` field name in one place and `created_at` in another), you should use `MappableWithContext` protocol, which conforms to `Mappable`:\r\n\r\n```swift\r\nstruct User: MappableWithContext {\r\n    \r\n    enum Context {\r\n        case json\r\n        case mongo\r\n    }\r\n    \r\n    let name: String\r\n    let identifier: String\r\n    \r\n    init<Map : MapProtocol>(mapper: ContextualMapper<Map, Context>) throws {\r\n        let context = mapper.context ?? .json\r\n        self.name = try mapper.map(from: \"name\")\r\n        switch context {\r\n        case .json:\r\n            self.identifier = try mapper.map(from: \"id\")\r\n        case .mongo:\r\n            self.identifier = try mapper.map(from: \"identifier\")\r\n        }\r\n    }\r\n    \r\n}\r\n\r\nlet user = try User(from: userJSON, withContext: .json)\r\n```\r\n\r\nAnd if you want to nest `User` struct inside something else, you can have next type of behavior:\r\n\r\n```swift\r\nstruct UserBook: MappableWithContext {\r\n    \r\n    let users: [User]\r\n    \r\n    init<Map : MapProtocol>(mapper: ContextualMapper<Map, User.Context>) throws {\r\n        self.users = try mapper.map(arrayWithContextFrom: \"users\")\r\n    }\r\n    \r\n}\r\n```\r\n\r\nBecause `User` and `UserBook` share the same associated `Context`, you can just pass context to mapper without any overhead using `.map(withContextFrom:)` and `.map(arrayWithContextFrom:)` methods of `mapper`.\r\n\r\nYou can also do this:\r\n\r\n```swift\r\nstruct MongoUserBook: Mappable {\r\n    \r\n    let users: [User]\r\n    \r\n    init<Map : MapProtocol>(mapper: Mapper<Map>) throws {\r\n        self.users = try mapper.map(arrayFrom: \"users\", usingContext: .mongo)\r\n    }\r\n    \r\n}\r\n```\r\n\r\nThis PR depends on #34 ","created_at":"2016-08-11T13:57:00Z","updated_at":"2016-08-12T06:38:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b4a09532fca5b2dad331e79b3e5e9a48d85ce0b2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/QuarkX/Quark/pulls/35/commits","review_comments_url":"https://api.github.com/repos/QuarkX/Quark/pulls/35/comments","review_comment_url":"https://api.github.com/repos/QuarkX/Quark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/QuarkX/Quark/issues/35/comments","statuses_url":"https://api.github.com/repos/QuarkX/Quark/statuses/af7349371429cd5011e735e8375ff85214059075","head":{"label":"QuarkX:mapper","ref":"mapper","sha":"af7349371429cd5011e735e8375ff85214059075","user":{"login":"QuarkX","id":20213878,"avatar_url":"https://avatars.githubusercontent.com/u/20213878?v=3","gravatar_id":"","url":"https://api.github.com/users/QuarkX","html_url":"https://github.com/QuarkX","followers_url":"https://api.github.com/users/QuarkX/followers","following_url":"https://api.github.com/users/QuarkX/following{/other_user}","gists_url":"https://api.github.com/users/QuarkX/gists{/gist_id}","starred_url":"https://api.github.com/users/QuarkX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuarkX/subscriptions","organizations_url":"https://api.github.com/users/QuarkX/orgs","repos_url":"https://api.github.com/users/QuarkX/repos","events_url":"https://api.github.com/users/QuarkX/events{/privacy}","received_events_url":"https://api.github.com/users/QuarkX/received_events","type":"Organization","site_admin":false},"repo":{"id":62730944,"name":"Quark","full_name":"QuarkX/Quark","owner":{"login":"QuarkX","id":20213878,"avatar_url":"https://avatars.githubusercontent.com/u/20213878?v=3","gravatar_id":"","url":"https://api.github.com/users/QuarkX","html_url":"https://github.com/QuarkX","followers_url":"https://api.github.com/users/QuarkX/followers","following_url":"https://api.github.com/users/QuarkX/following{/other_user}","gists_url":"https://api.github.com/users/QuarkX/gists{/gist_id}","starred_url":"https://api.github.com/users/QuarkX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuarkX/subscriptions","organizations_url":"https://api.github.com/users/QuarkX/orgs","repos_url":"https://api.github.com/users/QuarkX/repos","events_url":"https://api.github.com/users/QuarkX/events{/privacy}","received_events_url":"https://api.github.com/users/QuarkX/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/QuarkX/Quark","description":"A clean web framework for modern Swift applications (macOS and Linux)","fork":false,"url":"https://api.github.com/repos/QuarkX/Quark","forks_url":"https://api.github.com/repos/QuarkX/Quark/forks","keys_url":"https://api.github.com/repos/QuarkX/Quark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/QuarkX/Quark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/QuarkX/Quark/teams","hooks_url":"https://api.github.com/repos/QuarkX/Quark/hooks","issue_events_url":"https://api.github.com/repos/QuarkX/Quark/issues/events{/number}","events_url":"https://api.github.com/repos/QuarkX/Quark/events","assignees_url":"https://api.github.com/repos/QuarkX/Quark/assignees{/user}","branches_url":"https://api.github.com/repos/QuarkX/Quark/branches{/branch}","tags_url":"https://api.github.com/repos/QuarkX/Quark/tags","blobs_url":"https://api.github.com/repos/QuarkX/Quark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/QuarkX/Quark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/QuarkX/Quark/git/refs{/sha}","trees_url":"https://api.github.com/repos/QuarkX/Quark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/QuarkX/Quark/statuses/{sha}","languages_url":"https://api.github.com/repos/QuarkX/Quark/languages","stargazers_url":"https://api.github.com/repos/QuarkX/Quark/stargazers","contributors_url":"https://api.github.com/repos/QuarkX/Quark/contributors","subscribers_url":"https://api.github.com/repos/QuarkX/Quark/subscribers","subscription_url":"https://api.github.com/repos/QuarkX/Quark/subscription","commits_url":"https://api.github.com/repos/QuarkX/Quark/commits{/sha}","git_commits_url":"https://api.github.com/repos/QuarkX/Quark/git/commits{/sha}","comments_url":"https://api.github.com/repos/QuarkX/Quark/comments{/number}","issue_comment_url":"https://api.github.com/repos/QuarkX/Quark/issues/comments{/number}","contents_url":"https://api.github.com/repos/QuarkX/Quark/contents/{+path}","compare_url":"https://api.github.com/repos/QuarkX/Quark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/QuarkX/Quark/merges","archive_url":"https://api.github.com/repos/QuarkX/Quark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/QuarkX/Quark/downloads","issues_url":"https://api.github.com/repos/QuarkX/Quark/issues{/number}","pulls_url":"https://api.github.com/repos/QuarkX/Quark/pulls{/number}","milestones_url":"https://api.github.com/repos/QuarkX/Quark/milestones{/number}","notifications_url":"https://api.github.com/repos/QuarkX/Quark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/QuarkX/Quark/labels{/name}","releases_url":"https://api.github.com/repos/QuarkX/Quark/releases{/id}","deployments_url":"https://api.github.com/repos/QuarkX/Quark/deployments","created_at":"2016-07-06T15:13:36Z","updated_at":"2016-08-11T20:16:27Z","pushed_at":"2016-08-12T06:38:00Z","git_url":"git://github.com/QuarkX/Quark.git","ssh_url":"git@github.com:QuarkX/Quark.git","clone_url":"https://github.com/QuarkX/Quark.git","svn_url":"https://github.com/QuarkX/Quark","homepage":"","size":1017,"stargazers_count":24,"watchers_count":24,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4,"mirror_url":null,"open_issues_count":6,"forks":4,"open_issues":6,"watchers":24,"default_branch":"master"}},"base":{"label":"QuarkX:master","ref":"master","sha":"d5ec2fa923608d4e5b47dd7a5d44d5b6693d1d79","user":{"login":"QuarkX","id":20213878,"avatar_url":"https://avatars.githubusercontent.com/u/20213878?v=3","gravatar_id":"","url":"https://api.github.com/users/QuarkX","html_url":"https://github.com/QuarkX","followers_url":"https://api.github.com/users/QuarkX/followers","following_url":"https://api.github.com/users/QuarkX/following{/other_user}","gists_url":"https://api.github.com/users/QuarkX/gists{/gist_id}","starred_url":"https://api.github.com/users/QuarkX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuarkX/subscriptions","organizations_url":"https://api.github.com/users/QuarkX/orgs","repos_url":"https://api.github.com/users/QuarkX/repos","events_url":"https://api.github.com/users/QuarkX/events{/privacy}","received_events_url":"https://api.github.com/users/QuarkX/received_events","type":"Organization","site_admin":false},"repo":{"id":62730944,"name":"Quark","full_name":"QuarkX/Quark","owner":{"login":"QuarkX","id":20213878,"avatar_url":"https://avatars.githubusercontent.com/u/20213878?v=3","gravatar_id":"","url":"https://api.github.com/users/QuarkX","html_url":"https://github.com/QuarkX","followers_url":"https://api.github.com/users/QuarkX/followers","following_url":"https://api.github.com/users/QuarkX/following{/other_user}","gists_url":"https://api.github.com/users/QuarkX/gists{/gist_id}","starred_url":"https://api.github.com/users/QuarkX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/QuarkX/subscriptions","organizations_url":"https://api.github.com/users/QuarkX/orgs","repos_url":"https://api.github.com/users/QuarkX/repos","events_url":"https://api.github.com/users/QuarkX/events{/privacy}","received_events_url":"https://api.github.com/users/QuarkX/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/QuarkX/Quark","description":"A clean web framework for modern Swift applications (macOS and Linux)","fork":false,"url":"https://api.github.com/repos/QuarkX/Quark","forks_url":"https://api.github.com/repos/QuarkX/Quark/forks","keys_url":"https://api.github.com/repos/QuarkX/Quark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/QuarkX/Quark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/QuarkX/Quark/teams","hooks_url":"https://api.github.com/repos/QuarkX/Quark/hooks","issue_events_url":"https://api.github.com/repos/QuarkX/Quark/issues/events{/number}","events_url":"https://api.github.com/repos/QuarkX/Quark/events","assignees_url":"https://api.github.com/repos/QuarkX/Quark/assignees{/user}","branches_url":"https://api.github.com/repos/QuarkX/Quark/branches{/branch}","tags_url":"https://api.github.com/repos/QuarkX/Quark/tags","blobs_url":"https://api.github.com/repos/QuarkX/Quark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/QuarkX/Quark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/QuarkX/Quark/git/refs{/sha}","trees_url":"https://api.github.com/repos/QuarkX/Quark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/QuarkX/Quark/statuses/{sha}","languages_url":"https://api.github.com/repos/QuarkX/Quark/languages","stargazers_url":"https://api.github.com/repos/QuarkX/Quark/stargazers","contributors_url":"https://api.github.com/repos/QuarkX/Quark/contributors","subscribers_url":"https://api.github.com/repos/QuarkX/Quark/subscribers","subscription_url":"https://api.github.com/repos/QuarkX/Quark/subscription","commits_url":"https://api.github.com/repos/QuarkX/Quark/commits{/sha}","git_commits_url":"https://api.github.com/repos/QuarkX/Quark/git/commits{/sha}","comments_url":"https://api.github.com/repos/QuarkX/Quark/comments{/number}","issue_comment_url":"https://api.github.com/repos/QuarkX/Quark/issues/comments{/number}","contents_url":"https://api.github.com/repos/QuarkX/Quark/contents/{+path}","compare_url":"https://api.github.com/repos/QuarkX/Quark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/QuarkX/Quark/merges","archive_url":"https://api.github.com/repos/QuarkX/Quark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/QuarkX/Quark/downloads","issues_url":"https://api.github.com/repos/QuarkX/Quark/issues{/number}","pulls_url":"https://api.github.com/repos/QuarkX/Quark/pulls{/number}","milestones_url":"https://api.github.com/repos/QuarkX/Quark/milestones{/number}","notifications_url":"https://api.github.com/repos/QuarkX/Quark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/QuarkX/Quark/labels{/name}","releases_url":"https://api.github.com/repos/QuarkX/Quark/releases{/id}","deployments_url":"https://api.github.com/repos/QuarkX/Quark/deployments","created_at":"2016-07-06T15:13:36Z","updated_at":"2016-08-11T20:16:27Z","pushed_at":"2016-08-12T06:38:00Z","git_url":"git://github.com/QuarkX/Quark.git","ssh_url":"git@github.com:QuarkX/Quark.git","clone_url":"https://github.com/QuarkX/Quark.git","svn_url":"https://github.com/QuarkX/Quark","homepage":"","size":1017,"stargazers_count":24,"watchers_count":24,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4,"mirror_url":null,"open_issues_count":6,"forks":4,"open_issues":6,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/QuarkX/Quark/pulls/35"},"html":{"href":"https://github.com/QuarkX/Quark/pull/35"},"issue":{"href":"https://api.github.com/repos/QuarkX/Quark/issues/35"},"comments":{"href":"https://api.github.com/repos/QuarkX/Quark/issues/35/comments"},"review_comments":{"href":"https://api.github.com/repos/QuarkX/Quark/pulls/35/comments"},"review_comment":{"href":"https://api.github.com/repos/QuarkX/Quark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/QuarkX/Quark/pulls/35/commits"},"statuses":{"href":"https://api.github.com/repos/QuarkX/Quark/statuses/af7349371429cd5011e735e8375ff85214059075"}}}}
{"actor":{"display_login":"houndci-bot"}}