module MuchNotGiven

Constants

VERSION

Public Class Methods

new(receiver_name) click to toggle source
# File lib/much-not-given.rb, line 14
def initialize(receiver_name)
  @receiver_name = receiver_name
end

Public Instance Methods

==(other) click to toggle source
Calls superclass method
# File lib/much-not-given.rb, line 34
def ==(other)
  if other.is_a?(self.class)
    true
  else
    super
  end
end
blank?() click to toggle source
# File lib/much-not-given.rb, line 18
def blank?
  true
end
given?(value) click to toggle source
# File lib/much-not-given.rb, line 49
def given?(value)
  value != not_given
end
inspect() click to toggle source
# File lib/much-not-given.rb, line 30
def inspect
  to_s
end
not_given() click to toggle source
# File lib/much-not-given.rb, line 10
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(inspect)
    end
end
not_given?(value) click to toggle source
# File lib/much-not-given.rb, line 45
def not_given?(value)
  value == not_given
end
present?() click to toggle source
# File lib/much-not-given.rb, line 22
def present?
  false
end
to_s() click to toggle source
# File lib/much-not-given.rb, line 26
def to_s
  "#{@receiver_name}.not_given"
end