{"action":"created","comment":{"url":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/comments/90821156","pull_request_review_id":11335488,"id":90821156,"diff_hunk":"@@ -21,41 +21,71 @@ class Field\n \n       # Initializes a Field instance given the definition passed to the\n       # scoped_search call on the ActiveRecord-based model class.\n-      def initialize(definition, options = {})\n-        @definition = definition\n-        @definition.profile = options[:profile] if options[:profile]\n-        @definition.default_order ||= default_order(options)\n-\n-        case options\n-        when Symbol, String\n-          @field = field.to_sym\n-        when Hash\n-          @field = options.delete(:on)\n-\n-          # Set attributes from options hash\n-          @complete_value   = options[:complete_value]\n-          @relation         = options[:in]\n-          @key_relation     = options[:in_key]\n-          @key_field        = options[:on_key]\n-          @offset           = options[:offset]\n-          @word_size        = options[:word_size] || 1\n-          @ext_method       = options[:ext_method]\n-          @operators        = options[:operators]\n-          @only_explicit    = !!options[:only_explicit]\n-          @full_text_search = options[:full_text_search]\n-          @default_operator = options[:default_operator] if options.has_key?(:default_operator)\n-          @complete_enabled = options[:complete_enabled].nil? ? true : options[:complete_enabled]\n-          @validator        = options[:validator]\n+      #\n+      # Field name may be given in positional 'field' argument or 'on' named\n+      # argument.\n+      def initialize(definition,\n+                     field = nil,\n+                     aliases: [],\n+                     complete_enabled: true,\n+                     complete_value: nil,\n+                     default_operator: nil,\n+                     default_order: nil,\n+                     ext_method: nil,\n+                     full_text_search: nil,\n+                     in_key: nil,\n+                     offset: nil,\n+                     on: field,\n+                     on_key: nil,\n+                     only_explicit: nil,\n+                     operators: nil,\n+                     profile: nil,\n+                     relation: nil,\n+                     rename: nil,\n+                     validator: nil,\n+                     word_size: 1,\n+                     **kwargs)\n+\n+        # Prefer 'on' kw arg if given, defaults to the 'field' positional to allow either syntax\n+        raise ArgumentError, \"Missing field or 'on' keyword argument\" if on.nil?","path":"lib/scoped_search/definition.rb","position":55,"original_position":55,"commit_id":"b8536e324433b85b264fe7d79e7b664cb4475f5e","original_commit_id":"b8536e324433b85b264fe7d79e7b664cb4475f5e","user":{"login":"domcleal","id":482089,"avatar_url":"https://avatars.githubusercontent.com/u/482089?v=3","gravatar_id":"","url":"https://api.github.com/users/domcleal","html_url":"https://github.com/domcleal","followers_url":"https://api.github.com/users/domcleal/followers","following_url":"https://api.github.com/users/domcleal/following{/other_user}","gists_url":"https://api.github.com/users/domcleal/gists{/gist_id}","starred_url":"https://api.github.com/users/domcleal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domcleal/subscriptions","organizations_url":"https://api.github.com/users/domcleal/orgs","repos_url":"https://api.github.com/users/domcleal/repos","events_url":"https://api.github.com/users/domcleal/events{/privacy}","received_events_url":"https://api.github.com/users/domcleal/received_events","type":"User","site_admin":false},"body":"Not without removing support for `scoped_search :my_field` with the first positional argument instead of `:on => :my_field`. Setting `:on` to be required would mandate the keyword syntax, while now it's backwards-compatible with the current accepted scoped_search args.\r\n\r\nI like the simple non-keyword syntax for single fields so would rather leave this as-is, and would rather not break compat.","created_at":"2016-12-05T08:45:30Z","updated_at":"2016-12-05T08:45:31Z","html_url":"https://github.com/wvanbergen/scoped_search/pull/155#discussion_r90821156","pull_request_url":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/155","_links":{"self":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/comments/90821156"},"html":{"href":"https://github.com/wvanbergen/scoped_search/pull/155#discussion_r90821156"},"pull_request":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/155"}}},"pull_request":{"url":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/155","id":96289075,"html_url":"https://github.com/wvanbergen/scoped_search/pull/155","diff_url":"https://github.com/wvanbergen/scoped_search/pull/155.diff","patch_url":"https://github.com/wvanbergen/scoped_search/pull/155.patch","issue_url":"https://api.github.com/repos/wvanbergen/scoped_search/issues/155","number":155,"state":"open","locked":false,"title":"Convert Definition::Field.new to keyword arguments","user":{"login":"domcleal","id":482089,"avatar_url":"https://avatars.githubusercontent.com/u/482089?v=3","gravatar_id":"","url":"https://api.github.com/users/domcleal","html_url":"https://github.com/domcleal","followers_url":"https://api.github.com/users/domcleal/followers","following_url":"https://api.github.com/users/domcleal/following{/other_user}","gists_url":"https://api.github.com/users/domcleal/gists{/gist_id}","starred_url":"https://api.github.com/users/domcleal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domcleal/subscriptions","organizations_url":"https://api.github.com/users/domcleal/orgs","repos_url":"https://api.github.com/users/domcleal/repos","events_url":"https://api.github.com/users/domcleal/events{/privacy}","received_events_url":"https://api.github.com/users/domcleal/received_events","type":"User","site_admin":false},"body":"I've added deprecations and workarounds for `:in` and `:alias` because they're the names of reserved words in Ruby. Improvements to the suggested replacements of `:relation` and `:aliases` welcome. Alternatively I can leave them undeprecated, but it'd be cleaner if they didn't exist.\r\n\r\n","created_at":"2016-12-02T14:30:04Z","updated_at":"2016-12-05T08:45:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9ed50ec43061675ea80f750a816d454895d3c68a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/155/commits","review_comments_url":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/155/comments","review_comment_url":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wvanbergen/scoped_search/issues/155/comments","statuses_url":"https://api.github.com/repos/wvanbergen/scoped_search/statuses/b8536e324433b85b264fe7d79e7b664cb4475f5e","head":{"label":"domcleal:kwargs","ref":"kwargs","sha":"b8536e324433b85b264fe7d79e7b664cb4475f5e","user":{"login":"domcleal","id":482089,"avatar_url":"https://avatars.githubusercontent.com/u/482089?v=3","gravatar_id":"","url":"https://api.github.com/users/domcleal","html_url":"https://github.com/domcleal","followers_url":"https://api.github.com/users/domcleal/followers","following_url":"https://api.github.com/users/domcleal/following{/other_user}","gists_url":"https://api.github.com/users/domcleal/gists{/gist_id}","starred_url":"https://api.github.com/users/domcleal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domcleal/subscriptions","organizations_url":"https://api.github.com/users/domcleal/orgs","repos_url":"https://api.github.com/users/domcleal/repos","events_url":"https://api.github.com/users/domcleal/events{/privacy}","received_events_url":"https://api.github.com/users/domcleal/received_events","type":"User","site_admin":false},"repo":{"id":35411402,"name":"scoped_search","full_name":"domcleal/scoped_search","owner":{"login":"domcleal","id":482089,"avatar_url":"https://avatars.githubusercontent.com/u/482089?v=3","gravatar_id":"","url":"https://api.github.com/users/domcleal","html_url":"https://github.com/domcleal","followers_url":"https://api.github.com/users/domcleal/followers","following_url":"https://api.github.com/users/domcleal/following{/other_user}","gists_url":"https://api.github.com/users/domcleal/gists{/gist_id}","starred_url":"https://api.github.com/users/domcleal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domcleal/subscriptions","organizations_url":"https://api.github.com/users/domcleal/orgs","repos_url":"https://api.github.com/users/domcleal/repos","events_url":"https://api.github.com/users/domcleal/events{/privacy}","received_events_url":"https://api.github.com/users/domcleal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/domcleal/scoped_search","description":"Easily search you ActiveRecord models with a simple query language that converts to SQL.","fork":true,"url":"https://api.github.com/repos/domcleal/scoped_search","forks_url":"https://api.github.com/repos/domcleal/scoped_search/forks","keys_url":"https://api.github.com/repos/domcleal/scoped_search/keys{/key_id}","collaborators_url":"https://api.github.com/repos/domcleal/scoped_search/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/domcleal/scoped_search/teams","hooks_url":"https://api.github.com/repos/domcleal/scoped_search/hooks","issue_events_url":"https://api.github.com/repos/domcleal/scoped_search/issues/events{/number}","events_url":"https://api.github.com/repos/domcleal/scoped_search/events","assignees_url":"https://api.github.com/repos/domcleal/scoped_search/assignees{/user}","branches_url":"https://api.github.com/repos/domcleal/scoped_search/branches{/branch}","tags_url":"https://api.github.com/repos/domcleal/scoped_search/tags","blobs_url":"https://api.github.com/repos/domcleal/scoped_search/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/domcleal/scoped_search/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/domcleal/scoped_search/git/refs{/sha}","trees_url":"https://api.github.com/repos/domcleal/scoped_search/git/trees{/sha}","statuses_url":"https://api.github.com/repos/domcleal/scoped_search/statuses/{sha}","languages_url":"https://api.github.com/repos/domcleal/scoped_search/languages","stargazers_url":"https://api.github.com/repos/domcleal/scoped_search/stargazers","contributors_url":"https://api.github.com/repos/domcleal/scoped_search/contributors","subscribers_url":"https://api.github.com/repos/domcleal/scoped_search/subscribers","subscription_url":"https://api.github.com/repos/domcleal/scoped_search/subscription","commits_url":"https://api.github.com/repos/domcleal/scoped_search/commits{/sha}","git_commits_url":"https://api.github.com/repos/domcleal/scoped_search/git/commits{/sha}","comments_url":"https://api.github.com/repos/domcleal/scoped_search/comments{/number}","issue_comment_url":"https://api.github.com/repos/domcleal/scoped_search/issues/comments{/number}","contents_url":"https://api.github.com/repos/domcleal/scoped_search/contents/{+path}","compare_url":"https://api.github.com/repos/domcleal/scoped_search/compare/{base}...{head}","merges_url":"https://api.github.com/repos/domcleal/scoped_search/merges","archive_url":"https://api.github.com/repos/domcleal/scoped_search/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/domcleal/scoped_search/downloads","issues_url":"https://api.github.com/repos/domcleal/scoped_search/issues{/number}","pulls_url":"https://api.github.com/repos/domcleal/scoped_search/pulls{/number}","milestones_url":"https://api.github.com/repos/domcleal/scoped_search/milestones{/number}","notifications_url":"https://api.github.com/repos/domcleal/scoped_search/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/domcleal/scoped_search/labels{/name}","releases_url":"https://api.github.com/repos/domcleal/scoped_search/releases{/id}","deployments_url":"https://api.github.com/repos/domcleal/scoped_search/deployments","created_at":"2015-05-11T08:27:02Z","updated_at":"2015-05-11T08:27:02Z","pushed_at":"2016-12-02T15:05:08Z","git_url":"git://github.com/domcleal/scoped_search.git","ssh_url":"git@github.com:domcleal/scoped_search.git","clone_url":"https://github.com/domcleal/scoped_search.git","svn_url":"https://github.com/domcleal/scoped_search","homepage":"","size":718,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wvanbergen:master","ref":"master","sha":"d02ea1a2902a28862af81829804f8180251a9953","user":{"login":"wvanbergen","id":15870,"avatar_url":"https://avatars.githubusercontent.com/u/15870?v=3","gravatar_id":"","url":"https://api.github.com/users/wvanbergen","html_url":"https://github.com/wvanbergen","followers_url":"https://api.github.com/users/wvanbergen/followers","following_url":"https://api.github.com/users/wvanbergen/following{/other_user}","gists_url":"https://api.github.com/users/wvanbergen/gists{/gist_id}","starred_url":"https://api.github.com/users/wvanbergen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wvanbergen/subscriptions","organizations_url":"https://api.github.com/users/wvanbergen/orgs","repos_url":"https://api.github.com/users/wvanbergen/repos","events_url":"https://api.github.com/users/wvanbergen/events{/privacy}","received_events_url":"https://api.github.com/users/wvanbergen/received_events","type":"User","site_admin":false},"repo":{"id":37427,"name":"scoped_search","full_name":"wvanbergen/scoped_search","owner":{"login":"wvanbergen","id":15870,"avatar_url":"https://avatars.githubusercontent.com/u/15870?v=3","gravatar_id":"","url":"https://api.github.com/users/wvanbergen","html_url":"https://github.com/wvanbergen","followers_url":"https://api.github.com/users/wvanbergen/followers","following_url":"https://api.github.com/users/wvanbergen/following{/other_user}","gists_url":"https://api.github.com/users/wvanbergen/gists{/gist_id}","starred_url":"https://api.github.com/users/wvanbergen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wvanbergen/subscriptions","organizations_url":"https://api.github.com/users/wvanbergen/orgs","repos_url":"https://api.github.com/users/wvanbergen/repos","events_url":"https://api.github.com/users/wvanbergen/events{/privacy}","received_events_url":"https://api.github.com/users/wvanbergen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wvanbergen/scoped_search","description":"Easily search you ActiveRecord models with a simple query language that converts to SQL.","fork":false,"url":"https://api.github.com/repos/wvanbergen/scoped_search","forks_url":"https://api.github.com/repos/wvanbergen/scoped_search/forks","keys_url":"https://api.github.com/repos/wvanbergen/scoped_search/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wvanbergen/scoped_search/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wvanbergen/scoped_search/teams","hooks_url":"https://api.github.com/repos/wvanbergen/scoped_search/hooks","issue_events_url":"https://api.github.com/repos/wvanbergen/scoped_search/issues/events{/number}","events_url":"https://api.github.com/repos/wvanbergen/scoped_search/events","assignees_url":"https://api.github.com/repos/wvanbergen/scoped_search/assignees{/user}","branches_url":"https://api.github.com/repos/wvanbergen/scoped_search/branches{/branch}","tags_url":"https://api.github.com/repos/wvanbergen/scoped_search/tags","blobs_url":"https://api.github.com/repos/wvanbergen/scoped_search/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wvanbergen/scoped_search/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wvanbergen/scoped_search/git/refs{/sha}","trees_url":"https://api.github.com/repos/wvanbergen/scoped_search/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wvanbergen/scoped_search/statuses/{sha}","languages_url":"https://api.github.com/repos/wvanbergen/scoped_search/languages","stargazers_url":"https://api.github.com/repos/wvanbergen/scoped_search/stargazers","contributors_url":"https://api.github.com/repos/wvanbergen/scoped_search/contributors","subscribers_url":"https://api.github.com/repos/wvanbergen/scoped_search/subscribers","subscription_url":"https://api.github.com/repos/wvanbergen/scoped_search/subscription","commits_url":"https://api.github.com/repos/wvanbergen/scoped_search/commits{/sha}","git_commits_url":"https://api.github.com/repos/wvanbergen/scoped_search/git/commits{/sha}","comments_url":"https://api.github.com/repos/wvanbergen/scoped_search/comments{/number}","issue_comment_url":"https://api.github.com/repos/wvanbergen/scoped_search/issues/comments{/number}","contents_url":"https://api.github.com/repos/wvanbergen/scoped_search/contents/{+path}","compare_url":"https://api.github.com/repos/wvanbergen/scoped_search/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wvanbergen/scoped_search/merges","archive_url":"https://api.github.com/repos/wvanbergen/scoped_search/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wvanbergen/scoped_search/downloads","issues_url":"https://api.github.com/repos/wvanbergen/scoped_search/issues{/number}","pulls_url":"https://api.github.com/repos/wvanbergen/scoped_search/pulls{/number}","milestones_url":"https://api.github.com/repos/wvanbergen/scoped_search/milestones{/number}","notifications_url":"https://api.github.com/repos/wvanbergen/scoped_search/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wvanbergen/scoped_search/labels{/name}","releases_url":"https://api.github.com/repos/wvanbergen/scoped_search/releases{/id}","deployments_url":"https://api.github.com/repos/wvanbergen/scoped_search/deployments","created_at":"2008-07-26T13:46:16Z","updated_at":"2016-11-15T01:35:41Z","pushed_at":"2016-12-02T15:05:08Z","git_url":"git://github.com/wvanbergen/scoped_search.git","ssh_url":"git@github.com:wvanbergen/scoped_search.git","clone_url":"https://github.com/wvanbergen/scoped_search.git","svn_url":"https://github.com/wvanbergen/scoped_search","homepage":"","size":958,"stargazers_count":181,"watchers_count":181,"language":"Ruby","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":50,"mirror_url":null,"open_issues_count":15,"forks":50,"open_issues":15,"watchers":181,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/155"},"html":{"href":"https://github.com/wvanbergen/scoped_search/pull/155"},"issue":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/issues/155"},"comments":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/issues/155/comments"},"review_comments":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/155/comments"},"review_comment":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/pulls/155/commits"},"statuses":{"href":"https://api.github.com/repos/wvanbergen/scoped_search/statuses/b8536e324433b85b264fe7d79e7b664cb4475f5e"}}}}
{"actor":{"display_login":"domcleal"}}