Hacker News new | ask | show | jobs
by jbverschoor 4856 days ago
Is there a reason why it was not created with multiple commands / methods in mind? :

  class UserService
  service :signup do |config|
    config.required do end
    config.optional do end
    config.execute
        # signup stuff here
    end
  end
   
  service :delete_account do |config|
    config.required do end
    config.optional do end
    config.execute
        # signup stuff here
    end
  end
  end

This would also make it possible to do service description and even expose a json or xml api using just this.

But I guess the controllers are created for this. DHH says controllers are responsible for mailing and stuff, which is more correct than in the models with callbacks.

1 comments

It seems like what you've done there is create two mutations (signup and delete_account) within a single namespace. You can certainly do that with the Mutations gem.

What I think you're getting at is: can you just replace controllers with mutations? That's an interesting concept that I've thought a bit about. In practice, we have found controllers to still be useful in collecting some information and doing 'wiring'. They're also nice because your SOA shouldn't really be concerned with the presentation of the response.

Finally, where do you put your mailings? You're right that controllers > models, but I'd also say that mutations > controllers > models.