The title of this pull request changed from “WIP: DEV: Use AR enums in reviewables related code” to "DEV: Use AR enums in reviewables related code
Is there a way to avoid
public_send? That’s asking for trouble
Other than that use of
Well it allows to use the automatically defined scopes from AR and if the status isn’t a valid one for whatever reason it will break.
#who_did is a protected method and is only used in two places (L36 and L40), we control the value of
status, nothing inherits from
QueuedPostSerializer so I guess the trouble should be quite contained Wdyt?
If it’s used in just two places, with
:rejected as args, I would consider inlining this method. But I guess I’m fine with it as is too.
Oh, or a half-way inlining solution would work too, e.g.
def approved_by_id scope.approved.last&.created_by_id end def rejected_by_id scope.rejected.last&.created_by_id end protected # not necessarily the best name 😉 def scope object. reviewable_histories. transitioned. order(:created_at) end
Ah yes this hybrid solution seems nice enough I’m going to update the PR accordingly
Updated! I wasn’t that inspired either and went with
#post_history for the name.
Pushing this to 2.9