Namespace for operations

I have a question regarding the namespace for operations. I’m adding a notifier operation following the guides under Container and components. The guides state the operation should live in `app/operations/my_operation.rb`.

However, the generator puts it in either `app/my_operation.rb` or `app/notifiers/my_operation.rb`, if I pass the notifiers.my_operation to the CLI command.

Are these two the same operation and should the guides be updated or am I missing something?

I seem to recall some comment that operations are so important, that they are generated in the root of app/slice directory. But I always find it weird and put them back inside operations.

So you’d then have app/operations/some_operation.rb and / or app/slices/my_slice/operations/another_operation.rb?

Operations are part of your own domain logic, so you’re welcome to organise them however you like. This is why the generators do not force any particular opinion about a standard location.

I understand, thank you.

Yes, that’s how I do it (currently).

1 Like