policygenius / chief

Simple command object pattern for Ruby
MIT License
3 stars 1 forks source link

Force Chief::Command result to be a Chief::Result object #4

Closed smeriwether closed 6 years ago

smeriwether commented 6 years ago

After some discussion we think it is best practice to return a Chief::Result object from all Chief::Commands. We think this will lead to easier to reason about code.

An example:

class Example < Chief::Command
  def call
    some_other_chief_command
  end

  private

  def some_other_chief_command
    Command::DoSomething.call
  end
end

Code like this leads to a few questions:

By enforcing every Chief::Command to call success! or fail! we can force the developer to think about all of those questions and we can help the future developer better understand the command.