Sha256: 810bde40a5c28c4c93c9d5c8504c7f77bde3f5b93d335b8c40211512974547d0

Contents?: true

Size: 423 Bytes

Versions: 5

Compression:

Stored size: 423 Bytes

Contents

# frozen_string_literal: true

#
# lib/skn_utils/null_object.rb
#
module SknUtils

  # From: https://github.com/avdi/cowsay
  class NullObject
    def initialize
      @origin = caller.first
    end

    def __null_origin__
      @origin
    end

    def method_missing(*args, &block)
      self
    end

    def nil?
      true
    end
  end

  def self.nullable?(value)
    value.nil? ? NullObject.new : value
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
skn_utils-5.8.0 lib/skn_utils/null_object.rb
skn_utils-5.7.0 lib/skn_utils/null_object.rb
skn_utils-5.6.0 lib/skn_utils/null_object.rb
skn_utils-5.5.0 lib/skn_utils/null_object.rb
skn_utils-5.4.1 lib/skn_utils/null_object.rb