Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Params key in nested model operations is obtained messily #33

Closed
sudoremo opened this issue Feb 21, 2023 · 0 comments
Closed

Params key in nested model operations is obtained messily #33

sudoremo opened this issue Feb 21, 2023 · 0 comments

Comments

@sudoremo
Copy link
Contributor

Currently, when nesting model operations, a param_key has to be derived in order to assemble the parameters for the sub-operation. Consider the following:

class Operations::User::Create
  model User
  nest_model_op :group, Operations::Group::Create
end

class Operations::Group::Create
  model Group
end

In this case, the operation Operations::Group::Create must receive its parameters as, for example:

#   ┌ param_key
{ group: { name: 'My group' } }

The param is currently derived from the module the sub-operation resides in, in this example:

#                    ┌ param_key (downcased and underscored)
Operations::Group::Create

While this works if the standard naming schemes are used, it is certainly a very suboptimal solution. The correct solution is to use model.model_name.param_key instead. This should generally not break anything, assuming that all operation modules follow the naming conventions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant