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 35 def blank?(*modifiers) 36 if block_given? 37 return true if yield(dup).blank? 38 end 39 40 if modifiers.empty? 41 respond_to?(:empty?) ? empty? : !self 42 else 43 return true if blank? 44 45 modifiers.each { |modifier| 46 if respond_to?(modifier) 47 if modifier.to_s =~ /\?\z/ 48 return true if send(modifier) 49 else 50 return true if send(modifier).blank? 51 end 52 end 53 } 54 55 false 56 end 57 end
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 64 def void? 65 blank?(:zero?, :strip, :compact) 66 end
Also aliased as: vain?