Class: NilClass

Inherits:
Object show all
Defined in:
lib/gorillib/object/blank.rb,
lib/gorillib/object/try.rb,
lib/gorillib/serialization.rb,
lib/gorillib/object/try_dup.rb

Overview

class Numeric

Instance Method Summary collapse

Instance Method Details

#blank?TrueClass

Nil is always blank

nil.blank?        #=>  true

Returns:



52
53
54
# File 'lib/gorillib/object/blank.rb', line 52

def blank?
  true
end

#to_wire(options = {}) ⇒ Object



51
52
53
# File 'lib/gorillib/serialization.rb', line 51

def to_wire(options={})
  nil
end

#try(*args) ⇒ Object

Calling try on nil always returns nil. It becomes specially helpful when navigating through associations that may return nil.

Examples

nil.try(:name) # => nil

Without try

@person && !@person.children.blank? && @person.children.first.name

With try

@person.try(:children).try(:first).try(:name)


53
54
55
# File 'lib/gorillib/object/try.rb', line 53

def try(*args)
  nil
end

#try_dupObject



29
30
31
# File 'lib/gorillib/object/try_dup.rb', line 29

def try_dup
  self
end