Sha256: 66034a755394e0cea318a4fac611ae6c360b4bb1ac478323217fb7a346a94157

Contents?: true

Size: 936 Bytes

Versions: 1

Compression:

Stored size: 936 Bytes

Contents

# frozen_string_literal: true

require "much-not-given/version"
require "much-plugin"

module MuchNotGiven
  include MuchPlugin

  plugin_class_methods do
    def not_given
      @not_given ||=
        begin
          Class.new {
            def initialize(receiver_name)
              @receiver_name = receiver_name
            end

            def blank?
              true
            end

            def present?
              false
            end

            def to_s
              "#{@receiver_name}.not_given"
            end

            def inspect
              to_s
            end

            def ==(other)
              if other.is_a?(self.class)
                true
              else
                super
              end
            end
          }.new(self.inspect)
        end
    end

    def not_given?(value)
      value == not_given
    end

    def given?(value)
      value != not_given
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
much-not-given-0.1.1 lib/much-not-given.rb