Pattern Matching Interfaces in Ruby

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • dio

    Dio - Dive Into Objects - Ruby Pattern Matching interface for Objects which have none (yet) (by baweaver)

  • Pattern matching interfaces can be simulated using gems such as Dio for testing purposes. It does not act as a replacement, but rather a stand-in to test interfaces without full implementations.

  • matchable

    Pattern Matching interfaces in Ruby made easy

  • In the case of most applications the performance implication of using public_send should not be enough to cause concern, but there are tricks to dynamically compile against this using eval in case performance becomes an issue.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • Deconstructable - Simpler version of Matchable, same idea behind it

  • ast

    A library for working with Abstract Syntax Trees. (by whitequark)

  • There are cases which exist, such as s-expressions, where this recommendation does not necessarily hold true. Marc-Andre had noted this in a pull request to the Whitequark AST gem, using the following implementation instead:

  • HTTP

    HTTP (The Gem! a.k.a. http.rb) - a fast Ruby HTTP client with a chainable API, streaming support, and timeouts

  • I had submitted a PR against this repo, but I believe the two most interesting types to match against are responses and requests:

  • ruby

    The Ruby Programming Language

  • Note: This was merged into Ruby: https://github.com/ruby/ruby/pull/6216

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts