repeatable
repeatable copied to clipboard
Support Ruby 2.7+ Pattern Matching
Add #deconstruct_keys
to Expression::Base
and Schedule
so that they can be used in pattern matches.
In our products, we've been using #to_h
for this, and it would be nice sugar to have it built in.
A common example we've used in our products is building a humanized-readable version of a schedule. An extremely stripped down version might look something like this
case existing_user_schedule
in weekday: { weekday: }
"Every #{weekday}"
in day_in_month: { day: }
"Last #{day} of every month"
end