repeatable icon indicating copy to clipboard operation
repeatable copied to clipboard

Support Ruby 2.7+ Pattern Matching

Open danielma opened this issue 10 months ago • 0 comments

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

danielma avatar Apr 18 '24 23:04 danielma