envato / event_sourcery

A library for building event sourced applications in Ruby
MIT License
84 stars 10 forks source link

Event.persisted? is potentially misleading #235

Closed andyjdavis closed 11 months ago

andyjdavis commented 1 year ago

re https://github.com/envato/event_sourcery/issues/180

Event.persisted? actually just checks if the event has an ID. That behaviour may be surprising. I'm not sure what the best solution is currently however I have written a small test that clearly demonstrates the issue.

domon-envato commented 1 year ago

Event.persisted? actually just checks if the event has an ID.

How is this method used?

I quickly searched the term persisted in event_sourcery and event_sourcery-postgres but could not find any usage of this method.

Can we potentially remove this method?

andyjdavis commented 1 year ago

I am certainly open to simply removing the persisted? method. It seems rather low value with event_sourcery users being able to replicate its functionality very easily

# Is this event persisted?
    def persisted?
      !id.nil?
    end

I will repurpose this PR to remove the event.persisted? method.

Simultaneously I plan to bump the version to 1.0.0 as the removal of persisted? is a breaking change.

andyjdavis commented 1 year ago

I have updated this PR to just remove Event.persisted?

I needed to bump the version and, barring any objections, I suggest that we go to 1.0.0. Removing Event.persisted? is a small changed but is a breaking change. Alternatively, it could just go to 0.25.0

I have also updated the readme to have a development status similar to the readme in https://github.com/envato/rack-ecg/ and removed the text about this repo undergoing rapid development as that isn't accurate.