{"action":"created","comment":{"url":"https://api.github.com/repos/babbel/dynameister/pulls/comments/54241963","id":54241963,"diff_hunk":"@@ -0,0 +1,47 @@\n+require \"dynameister/data_types\"\n+require_relative \"errors\"\n+\n+module Dynameister\n+\n+  class Coercer","path":"lib/dynameister/coercer.rb","position":6,"original_position":6,"commit_id":"652b0ddd1d94d9893b188b869d455c731f364b68","original_commit_id":"652b0ddd1d94d9893b188b869d455c731f364b68","user":{"login":"pixelpogo","id":284758,"avatar_url":"https://avatars.githubusercontent.com/u/284758?v=3","gravatar_id":"","url":"https://api.github.com/users/pixelpogo","html_url":"https://github.com/pixelpogo","followers_url":"https://api.github.com/users/pixelpogo/followers","following_url":"https://api.github.com/users/pixelpogo/following{/other_user}","gists_url":"https://api.github.com/users/pixelpogo/gists{/gist_id}","starred_url":"https://api.github.com/users/pixelpogo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pixelpogo/subscriptions","organizations_url":"https://api.github.com/users/pixelpogo/orgs","repos_url":"https://api.github.com/users/pixelpogo/repos","events_url":"https://api.github.com/users/pixelpogo/events{/privacy}","received_events_url":"https://api.github.com/users/pixelpogo/received_events","type":"User","site_admin":false},"body":"I like the idea of having a dedicated class to enforce, or coerce, the data type, but as we currently have only one use case, coercing datatypes for keys, would IMHO be better to have it named less generic. Maybe rename it to `DataTypeCoercer` or put it in the `DatatTypes` namespace?","created_at":"2016-02-26T13:26:43Z","updated_at":"2016-02-26T13:26:43Z","html_url":"https://github.com/babbel/dynameister/pull/14#discussion_r54241963","pull_request_url":"https://api.github.com/repos/babbel/dynameister/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/babbel/dynameister/pulls/comments/54241963"},"html":{"href":"https://github.com/babbel/dynameister/pull/14#discussion_r54241963"},"pull_request":{"href":"https://api.github.com/repos/babbel/dynameister/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/babbel/dynameister/pulls/14","id":59808018,"html_url":"https://github.com/babbel/dynameister/pull/14","diff_url":"https://github.com/babbel/dynameister/pull/14.diff","patch_url":"https://github.com/babbel/dynameister/pull/14.patch","issue_url":"https://api.github.com/repos/babbel/dynameister/issues/14","number":14,"state":"open","locked":false,"title":"Data types for table definition attributes","user":{"login":"nicsnet","id":1889716,"avatar_url":"https://avatars.githubusercontent.com/u/1889716?v=3","gravatar_id":"","url":"https://api.github.com/users/nicsnet","html_url":"https://github.com/nicsnet","followers_url":"https://api.github.com/users/nicsnet/followers","following_url":"https://api.github.com/users/nicsnet/following{/other_user}","gists_url":"https://api.github.com/users/nicsnet/gists{/gist_id}","starred_url":"https://api.github.com/users/nicsnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicsnet/subscriptions","organizations_url":"https://api.github.com/users/nicsnet/orgs","repos_url":"https://api.github.com/users/nicsnet/repos","events_url":"https://api.github.com/users/nicsnet/events{/privacy}","received_events_url":"https://api.github.com/users/nicsnet/received_events","type":"User","site_admin":false},"body":"Fixes https://github.com/babbel/dynameister/issues/5 . For table creation, the `hash_key` and `range_key` data types are derived from their respective field definitions and then mapped to their corresponding data type equivalent in the DynamoDB data store. This also applies for the creation of local and global indexes. Note that their data type can still be overridden, if explicitly passed in as a hash argument to the respective methods (as before). The default data type for all keys is now `:string`.\r\n\r\n| Dynameister data type  | DynamoDB data type |\r\n| ------------- | ------------- |\r\n| datetime  | string  |\r\n| time  | string  |\r\n| float | number |\r\n| integer | number |\r\n\r\nThe following model\r\n```ruby\r\nclass PetFood\r\n  include Dynameister::Document\r\n\r\n  field :valid_until, :datetime\r\n  field :created_at,  :time\r\n\r\n  table hash_key: :valid_until, range_key: :created_at \r\nend\r\n```\r\n\r\nWould create a table with the following attribute definitions:\r\n```ruby\r\n# List of all attributes which are used as table keys\r\nattribute_definitions:\r\n  [\r\n      { attribute_name: \"valid_until\", attribute_type: \"S\" },\r\n      { attribute_name: \"created_at\", attribute_type: \"S\" } \r\n ]\r\n```\r\n\r\n@pixelpogo @laurens @baschtl @dakeyras7 please review","created_at":"2016-02-18T14:43:23Z","updated_at":"2016-02-26T13:26:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e94f2a723ce5e5a654a53207c7e60dc63a928c90","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/babbel/dynameister/pulls/14/commits","review_comments_url":"https://api.github.com/repos/babbel/dynameister/pulls/14/comments","review_comment_url":"https://api.github.com/repos/babbel/dynameister/pulls/comments{/number}","comments_url":"https://api.github.com/repos/babbel/dynameister/issues/14/comments","statuses_url":"https://api.github.com/repos/babbel/dynameister/statuses/652b0ddd1d94d9893b188b869d455c731f364b68","head":{"label":"babbel:data_types_for_table_definition_attributes","ref":"data_types_for_table_definition_attributes","sha":"652b0ddd1d94d9893b188b869d455c731f364b68","user":{"login":"babbel","id":2762251,"avatar_url":"https://avatars.githubusercontent.com/u/2762251?v=3","gravatar_id":"","url":"https://api.github.com/users/babbel","html_url":"https://github.com/babbel","followers_url":"https://api.github.com/users/babbel/followers","following_url":"https://api.github.com/users/babbel/following{/other_user}","gists_url":"https://api.github.com/users/babbel/gists{/gist_id}","starred_url":"https://api.github.com/users/babbel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/babbel/subscriptions","organizations_url":"https://api.github.com/users/babbel/orgs","repos_url":"https://api.github.com/users/babbel/repos","events_url":"https://api.github.com/users/babbel/events{/privacy}","received_events_url":"https://api.github.com/users/babbel/received_events","type":"Organization","site_admin":false},"repo":{"id":47175689,"name":"dynameister","full_name":"babbel/dynameister","owner":{"login":"babbel","id":2762251,"avatar_url":"https://avatars.githubusercontent.com/u/2762251?v=3","gravatar_id":"","url":"https://api.github.com/users/babbel","html_url":"https://github.com/babbel","followers_url":"https://api.github.com/users/babbel/followers","following_url":"https://api.github.com/users/babbel/following{/other_user}","gists_url":"https://api.github.com/users/babbel/gists{/gist_id}","starred_url":"https://api.github.com/users/babbel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/babbel/subscriptions","organizations_url":"https://api.github.com/users/babbel/orgs","repos_url":"https://api.github.com/users/babbel/repos","events_url":"https://api.github.com/users/babbel/events{/privacy}","received_events_url":"https://api.github.com/users/babbel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/babbel/dynameister","description":"A Ruby Convenience Wrapper from Amazon's DynamoDB","fork":false,"url":"https://api.github.com/repos/babbel/dynameister","forks_url":"https://api.github.com/repos/babbel/dynameister/forks","keys_url":"https://api.github.com/repos/babbel/dynameister/keys{/key_id}","collaborators_url":"https://api.github.com/repos/babbel/dynameister/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/babbel/dynameister/teams","hooks_url":"https://api.github.com/repos/babbel/dynameister/hooks","issue_events_url":"https://api.github.com/repos/babbel/dynameister/issues/events{/number}","events_url":"https://api.github.com/repos/babbel/dynameister/events","assignees_url":"https://api.github.com/repos/babbel/dynameister/assignees{/user}","branches_url":"https://api.github.com/repos/babbel/dynameister/branches{/branch}","tags_url":"https://api.github.com/repos/babbel/dynameister/tags","blobs_url":"https://api.github.com/repos/babbel/dynameister/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/babbel/dynameister/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/babbel/dynameister/git/refs{/sha}","trees_url":"https://api.github.com/repos/babbel/dynameister/git/trees{/sha}","statuses_url":"https://api.github.com/repos/babbel/dynameister/statuses/{sha}","languages_url":"https://api.github.com/repos/babbel/dynameister/languages","stargazers_url":"https://api.github.com/repos/babbel/dynameister/stargazers","contributors_url":"https://api.github.com/repos/babbel/dynameister/contributors","subscribers_url":"https://api.github.com/repos/babbel/dynameister/subscribers","subscription_url":"https://api.github.com/repos/babbel/dynameister/subscription","commits_url":"https://api.github.com/repos/babbel/dynameister/commits{/sha}","git_commits_url":"https://api.github.com/repos/babbel/dynameister/git/commits{/sha}","comments_url":"https://api.github.com/repos/babbel/dynameister/comments{/number}","issue_comment_url":"https://api.github.com/repos/babbel/dynameister/issues/comments{/number}","contents_url":"https://api.github.com/repos/babbel/dynameister/contents/{+path}","compare_url":"https://api.github.com/repos/babbel/dynameister/compare/{base}...{head}","merges_url":"https://api.github.com/repos/babbel/dynameister/merges","archive_url":"https://api.github.com/repos/babbel/dynameister/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/babbel/dynameister/downloads","issues_url":"https://api.github.com/repos/babbel/dynameister/issues{/number}","pulls_url":"https://api.github.com/repos/babbel/dynameister/pulls{/number}","milestones_url":"https://api.github.com/repos/babbel/dynameister/milestones{/number}","notifications_url":"https://api.github.com/repos/babbel/dynameister/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/babbel/dynameister/labels{/name}","releases_url":"https://api.github.com/repos/babbel/dynameister/releases{/id}","deployments_url":"https://api.github.com/repos/babbel/dynameister/deployments","created_at":"2015-12-01T08:20:51Z","updated_at":"2016-02-23T09:38:09Z","pushed_at":"2016-02-26T10:48:00Z","git_url":"git://github.com/babbel/dynameister.git","ssh_url":"git@github.com:babbel/dynameister.git","clone_url":"https://github.com/babbel/dynameister.git","svn_url":"https://github.com/babbel/dynameister","homepage":null,"size":277,"stargazers_count":6,"watchers_count":6,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":6,"default_branch":"master"}},"base":{"label":"babbel:master","ref":"master","sha":"4dda1eef20e169803428f5a0bd3928d24cac1047","user":{"login":"babbel","id":2762251,"avatar_url":"https://avatars.githubusercontent.com/u/2762251?v=3","gravatar_id":"","url":"https://api.github.com/users/babbel","html_url":"https://github.com/babbel","followers_url":"https://api.github.com/users/babbel/followers","following_url":"https://api.github.com/users/babbel/following{/other_user}","gists_url":"https://api.github.com/users/babbel/gists{/gist_id}","starred_url":"https://api.github.com/users/babbel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/babbel/subscriptions","organizations_url":"https://api.github.com/users/babbel/orgs","repos_url":"https://api.github.com/users/babbel/repos","events_url":"https://api.github.com/users/babbel/events{/privacy}","received_events_url":"https://api.github.com/users/babbel/received_events","type":"Organization","site_admin":false},"repo":{"id":47175689,"name":"dynameister","full_name":"babbel/dynameister","owner":{"login":"babbel","id":2762251,"avatar_url":"https://avatars.githubusercontent.com/u/2762251?v=3","gravatar_id":"","url":"https://api.github.com/users/babbel","html_url":"https://github.com/babbel","followers_url":"https://api.github.com/users/babbel/followers","following_url":"https://api.github.com/users/babbel/following{/other_user}","gists_url":"https://api.github.com/users/babbel/gists{/gist_id}","starred_url":"https://api.github.com/users/babbel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/babbel/subscriptions","organizations_url":"https://api.github.com/users/babbel/orgs","repos_url":"https://api.github.com/users/babbel/repos","events_url":"https://api.github.com/users/babbel/events{/privacy}","received_events_url":"https://api.github.com/users/babbel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/babbel/dynameister","description":"A Ruby Convenience Wrapper from Amazon's DynamoDB","fork":false,"url":"https://api.github.com/repos/babbel/dynameister","forks_url":"https://api.github.com/repos/babbel/dynameister/forks","keys_url":"https://api.github.com/repos/babbel/dynameister/keys{/key_id}","collaborators_url":"https://api.github.com/repos/babbel/dynameister/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/babbel/dynameister/teams","hooks_url":"https://api.github.com/repos/babbel/dynameister/hooks","issue_events_url":"https://api.github.com/repos/babbel/dynameister/issues/events{/number}","events_url":"https://api.github.com/repos/babbel/dynameister/events","assignees_url":"https://api.github.com/repos/babbel/dynameister/assignees{/user}","branches_url":"https://api.github.com/repos/babbel/dynameister/branches{/branch}","tags_url":"https://api.github.com/repos/babbel/dynameister/tags","blobs_url":"https://api.github.com/repos/babbel/dynameister/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/babbel/dynameister/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/babbel/dynameister/git/refs{/sha}","trees_url":"https://api.github.com/repos/babbel/dynameister/git/trees{/sha}","statuses_url":"https://api.github.com/repos/babbel/dynameister/statuses/{sha}","languages_url":"https://api.github.com/repos/babbel/dynameister/languages","stargazers_url":"https://api.github.com/repos/babbel/dynameister/stargazers","contributors_url":"https://api.github.com/repos/babbel/dynameister/contributors","subscribers_url":"https://api.github.com/repos/babbel/dynameister/subscribers","subscription_url":"https://api.github.com/repos/babbel/dynameister/subscription","commits_url":"https://api.github.com/repos/babbel/dynameister/commits{/sha}","git_commits_url":"https://api.github.com/repos/babbel/dynameister/git/commits{/sha}","comments_url":"https://api.github.com/repos/babbel/dynameister/comments{/number}","issue_comment_url":"https://api.github.com/repos/babbel/dynameister/issues/comments{/number}","contents_url":"https://api.github.com/repos/babbel/dynameister/contents/{+path}","compare_url":"https://api.github.com/repos/babbel/dynameister/compare/{base}...{head}","merges_url":"https://api.github.com/repos/babbel/dynameister/merges","archive_url":"https://api.github.com/repos/babbel/dynameister/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/babbel/dynameister/downloads","issues_url":"https://api.github.com/repos/babbel/dynameister/issues{/number}","pulls_url":"https://api.github.com/repos/babbel/dynameister/pulls{/number}","milestones_url":"https://api.github.com/repos/babbel/dynameister/milestones{/number}","notifications_url":"https://api.github.com/repos/babbel/dynameister/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/babbel/dynameister/labels{/name}","releases_url":"https://api.github.com/repos/babbel/dynameister/releases{/id}","deployments_url":"https://api.github.com/repos/babbel/dynameister/deployments","created_at":"2015-12-01T08:20:51Z","updated_at":"2016-02-23T09:38:09Z","pushed_at":"2016-02-26T10:48:00Z","git_url":"git://github.com/babbel/dynameister.git","ssh_url":"git@github.com:babbel/dynameister.git","clone_url":"https://github.com/babbel/dynameister.git","svn_url":"https://github.com/babbel/dynameister","homepage":null,"size":277,"stargazers_count":6,"watchers_count":6,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/babbel/dynameister/pulls/14"},"html":{"href":"https://github.com/babbel/dynameister/pull/14"},"issue":{"href":"https://api.github.com/repos/babbel/dynameister/issues/14"},"comments":{"href":"https://api.github.com/repos/babbel/dynameister/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/babbel/dynameister/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/babbel/dynameister/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/babbel/dynameister/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/babbel/dynameister/statuses/652b0ddd1d94d9893b188b869d455c731f364b68"}}}}