Sha256: 7c1a2bb3dad497c24de9461e6d972521ed6041ee21d1829d85b57f1de63e6794
Contents?: true
Size: 609 Bytes
Versions: 1
Compression:
Stored size: 609 Bytes
Contents
module Tins # 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 to_f 0.0 end def to_i 0 end def to_a [] end def inspect 'NULL' end def nil? true end def blank? true end module Kernel def Null(value = nil) value.nil? ? Tins::NULL : value end end end NULL = Class.new(Module) do include Tins::Null end.new.freeze end require 'tins/alias'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tins-0.5.1 | lib/tins/null.rb |