Class: NilClass
- Defined in:
- lib/gorillib/object/blank.rb,
lib/gorillib/object/try.rb,
lib/gorillib/object/try_dup.rb,
lib/gorillib/serialization/to_wire.rb
Overview
class Numeric
Instance Method Summary collapse
-
#blank? ⇒ TrueClass
Nil is always blank.
- #to_wire(options = {}) ⇒ Object
-
#try(*args) ⇒ Object
Calling +try+ on +nil+ always returns +nil+.
- #try_dup ⇒ Object
Instance Method Details
#blank? ⇒ TrueClass
Nil is always blank
nil.blank? #=> true
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/to_wire.rb', line 51 def to_wire(={}) 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 && [email protected]? && @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_dup ⇒ Object
29 30 31 |
# File 'lib/gorillib/object/try_dup.rb', line 29 def try_dup self end |