Registry / utility / dry-matcher

dry-matcher

JSON →
library1.0.0rbrubygemsunverified

Flexible, expressive pattern matching for Ruby.

gem install dry-matcher
INSTALL
IMPORT
SIG · DRY-MATCHER
D
dry-matcher
utilityrubyv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Dry::Matcher
require 'dry/matcher'

Pattern matching on a result hash

require 'dry/matcher' matcher = Dry::Matcher.new( success: Dry::Matcher::Case.new(match: -> value { value[:status] == :ok }), failure: Dry::Matcher::Case.new(match: -> value { value[:status] == :error }) ) result = matcher.call({ status: :ok, data: 'Hello' }) do |m| m.success { |v| "Success: #{v[:data]}" } m.failure { |v| "Failure: #{v[:data]}" } end puts result
Debug
Known issues

No known issues recorded.

Upgrade
Version history
1.0.0latest on RubyGems
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
dry-matcher — gem install dry-matcher · libregistry