module Nuggets::Object::BlankMixin

Public Instance Methods

blank? → +true+ or +false+ click to toggle source

Basically a short-cut to object.nil? || object.empty?.

# File lib/nuggets/object/blank_mixin.rb, line 35
def blank?(*modifiers)
  if block_given?
    return true if yield(dup).blank?
  end

  if modifiers.empty?
    respond_to?(:empty?) ? empty? : !self
  else
    return true if blank?

    modifiers.each { |modifier|
      if respond_to?(modifier)
        if modifier.to_s =~ /\?\z/
          return true if send(modifier)
        else
          return true if send(modifier).blank?
        end
      end
    }

    false
  end
end
vain?()
Alias for: void?
void? → +true+ or +false+ click to toggle source

Adds white-space strings, 0 and arrays of nil objects to the list of blank objects.

# File lib/nuggets/object/blank_mixin.rb, line 64
def void?
  blank?(:zero?, :strip, :compact)
end
Also aliased as: vain?