Sha256: dc319bf12dc2d3a1a7f955861d938dfb103171aef2a33cf4a0bce1a27190554c

Contents?: true

Size: 308 Bytes

Versions: 6

Compression:

Stored size: 308 Bytes

Contents

module Spruz
  # Implementation of the null object pattern in Ruby.
  module Null
    def method_missing(*)
      self
    end

    def const_missing(*)
      self
    end

    def to_s
      ''
    end

    def inspect
      'NULL'
    end
  end

  NULL = Class.new do
    include Spruz::Null
  end.new
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spruz-0.2.13 lib/spruz/null.rb
spruz-0.2.12 lib/spruz/null.rb
spruz-0.2.11 lib/spruz/null.rb
spruz-0.2.10 lib/spruz/null.rb
spruz-0.2.9 lib/spruz/null.rb
spruz-0.2.8 lib/spruz/null.rb