Module: Mustermann::ToPattern
- Defined in:
- lib/mustermann/to_pattern.rb
Overview
Mixin for adding #to_pattern ducktyping to objects.
By default included into String, Symbol, Regexp, Array and Pattern.
Instance Method Summary collapse
-
#to_pattern(**options) ⇒ Mustermann::Pattern
Converts the object into a Pattern.
Instance Method Details
#to_pattern(**options) ⇒ Mustermann::Pattern
Converts the object into a Pattern.
40 41 42 43 44 |
# File 'lib/mustermann/to_pattern.rb', line 40 def to_pattern(**) input = self if PRIMITIVES.any? { |p| self.is_a? p } input ||= __getobj__ if respond_to?(:__getobj__) Mustermann.new(input || to_s, **) end |