{"action":"opened","issue":{"url":"https://api.github.com/repos/rom-rb/rom/issues/141","labels_url":"https://api.github.com/repos/rom-rb/rom/issues/141/labels{/name}","comments_url":"https://api.github.com/repos/rom-rb/rom/issues/141/comments","events_url":"https://api.github.com/repos/rom-rb/rom/issues/141/events","html_url":"https://github.com/rom-rb/rom/issues/141","id":56174608,"number":141,"title":"Refactor command evaluator to not depend on method_missing","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":[{"url":"https://api.github.com/repos/rom-rb/rom/labels/task","name":"task","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/rom-rb/rom/milestones/2","labels_url":"https://api.github.com/repos/rom-rb/rom/milestones/2/labels","id":945168,"number":2,"title":"1.0.0","description":null,"creator":{"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},"open_issues":5,"closed_issues":2,"state":"open","created_at":"2015-01-21T12:07:53Z","updated_at":"2015-02-01T19:30:30Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2015-02-01T19:30:30Z","updated_at":"2015-02-01T19:30:30Z","closed_at":null,"body":"Currently `ROM::Commands::Evaluator` relies on method missing to build a new command or execute it, ie:\r\n\r\n``` ruby\r\n# this does rom.commands.users.create.call(name: 'Jane')\r\nrom.command(:users).try { create(name: 'Jane') }\r\n\r\n# this does rom.commands.users.update.new(:by_id, 1).set(name: 'Jane')\r\nrom.command(:users).try { update(:by_id, 1).set(name: 'Jane') }\r\n```\r\n\r\nUnder the hood `Evaluator` has access to commands registry and finds a command by the name of the method called on it. So if you do `rom.command(:users).try { foo_bar }` it will look for `rom.commands.users.foo_bar` and crash if it's not there.\r\n\r\nIt might be a good idea to create an evaluator subclass for every command registry that explicitly defines methods that execute commands or create new ones.\r\n\r\nIt would also be worth to consider an alternative interface that would feel more OO, ie:\r\n\r\n``` ruby\r\nrom.command(:users).try { by_id(1).update(name: 'Jane') }\r\n\r\n# or\r\n\r\nrom.command(:users).try { by_id(1).delete }\r\n```"}}