{"action":"created","issue":{"url":"https://api.github.com/repos/gocardless/statesman/issues/118","labels_url":"https://api.github.com/repos/gocardless/statesman/issues/118/labels{/name}","comments_url":"https://api.github.com/repos/gocardless/statesman/issues/118/comments","events_url":"https://api.github.com/repos/gocardless/statesman/issues/118/events","html_url":"https://github.com/gocardless/statesman/issues/118","id":54989032,"number":118,"title":"State-driven instance behavior","user":{"login":"mtarnovan","id":4074,"avatar_url":"https://avatars.githubusercontent.com/u/4074?v=3","gravatar_id":"","url":"https://api.github.com/users/mtarnovan","html_url":"https://github.com/mtarnovan","followers_url":"https://api.github.com/users/mtarnovan/followers","following_url":"https://api.github.com/users/mtarnovan/following{/other_user}","gists_url":"https://api.github.com/users/mtarnovan/gists{/gist_id}","starred_url":"https://api.github.com/users/mtarnovan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtarnovan/subscriptions","organizations_url":"https://api.github.com/users/mtarnovan/orgs","repos_url":"https://api.github.com/users/mtarnovan/repos","events_url":"https://api.github.com/users/mtarnovan/events{/privacy}","received_events_url":"https://api.github.com/users/mtarnovan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-21T08:05:56Z","updated_at":"2015-01-21T12:38:58Z","closed_at":null,"body":"https://github.com/pluginaweek/state_machine has this and I find it very useful: the ability to define instance methods based on state.\r\n\r\nAny plans for such a feature in statesman?"},"comment":{"url":"https://api.github.com/repos/gocardless/statesman/issues/comments/70829595","html_url":"https://github.com/gocardless/statesman/issues/118#issuecomment-70829595","issue_url":"https://api.github.com/repos/gocardless/statesman/issues/118","id":70829595,"user":{"login":"mtarnovan","id":4074,"avatar_url":"https://avatars.githubusercontent.com/u/4074?v=3","gravatar_id":"","url":"https://api.github.com/users/mtarnovan","html_url":"https://github.com/mtarnovan","followers_url":"https://api.github.com/users/mtarnovan/followers","following_url":"https://api.github.com/users/mtarnovan/following{/other_user}","gists_url":"https://api.github.com/users/mtarnovan/gists{/gist_id}","starred_url":"https://api.github.com/users/mtarnovan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtarnovan/subscriptions","organizations_url":"https://api.github.com/users/mtarnovan/orgs","repos_url":"https://api.github.com/users/mtarnovan/repos","events_url":"https://api.github.com/users/mtarnovan/events{/privacy}","received_events_url":"https://api.github.com/users/mtarnovan/received_events","type":"User","site_admin":false},"created_at":"2015-01-21T12:38:58Z","updated_at":"2015-01-21T12:38:58Z","body":"Thanks for the reply Isaac. Yes, that's what I mean. Here's an example from state_machine's documentation:\r\n\r\n```ruby\r\n...\r\n    state all - [:parked, :stalled, :idling] do\r\n      def moving?\r\n        true\r\n      end\r\n    end\r\n\r\n    state :parked, :stalled, :idling do\r\n      def moving?\r\n        false\r\n      end\r\n    end\r\n...\r\n```\r\n\r\nIn practice, I find this useful for implementing different validations based on state, e.g.\r\n\r\n```ruby\r\nclass User\r\n...\r\n  state :new do\r\n    validates :email, presence: true\r\n  end\r\n\r\n  state :signed_up do\r\n    validates :email, :name, presence: true\r\n  end\r\n```\r\n\r\nHope this makes sense."}}