rom icon indicating copy to clipboard operation
rom copied to clipboard

Decouple Command from Relation

Open solnic opened this issue 4 years ago • 0 comments

At the moment commands rely on relation objects, which is problematic and makes configuration/setup and other features more complex. The reason why this is done like that is because in the early days relations didn't create commands, commands were completely standalone and they offered features that were partly provided by the relations, like restricting a command through a relation view.

Currently relations produce their own commands but they still inject themselves into the command constructor. This should be simplified by:

  • Commands should receive in its constructor a relation dataset instead of the whole relation
  • In addition to the dataset, commands constructors could receive a relation's mapper so that a command can return results that are mapped in the same way as if you used the relation itself to get results - this will only be needed by non-void commands (void-return commands will be done in 6.0 too, see #606)
  • Remove method_missing behavior that delegates relation view method calls, ie users.command(:update).by_pk(2).call(name: "Foo") is now possible, but this is redundant since you should be using relation instead: users.by_pk(2).command(:update).call(name: "Foo") - this behavior will be preserved

solnic avatar Jun 25 '20 08:06 solnic