Sha256: 317ed3c248f3dd819c36bab20b5c031618b548ac4d729ff33193ccc7636990e5
Contents?: true
Size: 874 Bytes
Versions: 2
Compression:
Stored size: 874 Bytes
Contents
module Koalemos module Full # Returns the object if it isn't blank (as in Object#blank?), otherwise it # returns nil. If a block was given as an argument and the object isn't # blank, the block is executed with the object as its first argument. If an # argument +dispatch+ was given and the object wasn't blank the method # given by dispatch is called on the object. This is the same as # foo.full?(&:bar) in the previous block form. def full?(dispatch = nil, *args) if blank? obj = nil #elsif Module === dispatch # TODO # dispatch.found?(self) elsif dispatch obj = __send__(dispatch, *args) obj = nil if obj.blank? else obj = self end if block_given? and obj yield obj else obj end end end class ::Object include Full end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
koalemos-0.0.2 | lib/koalemos/full.rb |
koalemos-0.0.1 | lib/koalemos/full.rb |