Module: Filigree::Destructurable

Included in:
Array
Defined in:
lib/filigree/match.rb

Overview

A module indicating that an object may be destructured. The including class must define the destructure instance method, which takes one argument specifying the number of pattern elements it is being matched against.

Instance Method Summary collapse

Instance Method Details

#call(*pattern) ⇒ DestructuringPattern

The instance method that generates a destructuring pattern.

Parameters:

  • pattern (Object)

    Sub-patterns used to match the destructured elements of the object.

Returns:



204
205
206
# File 'lib/filigree/match.rb', line 204

def call(*pattern)
  DestructuringPattern.new(self, Filigree::wrap_pattern_elements(pattern))
end