Module: Sevgi::Wet

Included in:
Sevgi
Defined in:
lib/sevgi/standard/internal/wet.rb

Constant Summary collapse

EMPTY_ARRAY =

Copied from github.com/dry-rb/dry-core. All kudos to the original authors.

[].freeze
EMPTY_HASH =
{}.freeze
EMPTY_OPTS =
{}.freeze
EMPTY_STRING =
""
IDENTITY =
(->(x) { x }).freeze
Undefined =

rubocop:disable Metrics/BlockLength

Object.new.tap do |undefined| # rubocop:disable Metrics/BlockLength
  const_set(:Self, -> { Undefined })

  def undefined.to_s                 = "Undefined"

  def undefined.inspect              = "Undefined"

  def undefined.default(x, y = self) = equal?(x) ? (equal?(y) ? yield : y) : x

  def undefined.map(value)           = equal?(value) ? self : yield(value)

  def undefined.dup                  = self

  def undefined.clone                = self

  def undefined.coalesce(*args)      = args.find(Self) { |x| !equal?(x) }
end.freeze

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



40
41
42
43
44
# File 'lib/sevgi/standard/internal/wet.rb', line 40

def self.included(base)
  super

  constants.each { |const_name| base.const_set(const_name, const_get(const_name)) }
end