copasetickid / draftsman

Ruby gem that lets you create draft versions of your database records.
MIT License
168 stars 62 forks source link

multiple drafts support #68

Closed yasser-sobhy closed 7 years ago

yasser-sobhy commented 7 years ago

Hi, I am using draftsman for a quite large project at my company, that project needs a multiple drafts functionality, unfortunately draftsman lakes for that. So I decided to support multiple drafts and push draftsman to version 1.

Changes:

To change:

chrisdpeters commented 7 years ago

@yasser-sobhy Thank you for the pull request!

I am very interested in this feature, but I think that some things would need to change with the implementation.

  1. Don't make it version 1. I'd probably release this as 0.7 or 0.8 honestly. So put those deprecated methods back in too. Focus this pull request just on the new feature instead of trying to manage the overall project.
  2. Create an optional setting on .has_drafts that lets the developer decide if they're going to have a single draft per record or multiple drafts.
  3. Bring #draft? back as an alias of #has_drafts? for the single draft scenario that I mention above.
  4. Change .has_draftsman back to .has_drafts. There is no real conflict there because that is a class-level method.

There is probably some opportunity to refactor this logic into includeable modules, kind of the way that concerns work in Rails. Maybe it should be architected so that the single draft and multiple draft strategies are their own modules that mix in common logic and implement the custom bits that each needs.

If you don't have the bandwidth to make these changes, I can probably get around to it eventually. I'll be honest though: I don't need this feature myself, so I don't have much motivation myself (though again, I'd love to see support for it).

Let's discuss. Anyone, jump in.

yasser-sobhy commented 7 years ago

@chrisdpeters I have cloned the latest Dratfsman with Rails 5.1 support and rewritten the changes again and separated single and multiple drafts functionality as you suggested. Have a look at my PR #71 .

chrisdpeters commented 7 years ago

Closing this in favor of #71.