Module: Tins::Null::Kernel
- Included in:
- Object
- Defined in:
- lib/tins/null.rb
Overview
Kernel extensions for null object creation.
Instance Method Summary collapse
-
#null(value = nil) ⇒ Object
(also: #Null)
Create a null object or return the provided value if not nil.
-
#null_plus(opts = {}) ⇒ Object
(also: #NullPlus)
Create a null object with additional debugging information.
Instance Method Details
#null(value = nil) ⇒ Object Also known as: Null
Create a null object or return the provided value if not nil.
114 115 116 |
# File 'lib/tins/null.rb', line 114 def null(value = nil) value.nil? ? Tins::NULL : value end |
#null_plus(opts = {}) ⇒ Object Also known as: NullPlus
Create a null object with additional debugging information.
This creates a NullPlus object that includes caller information for debugging purposes when the null object is used.
129 130 131 132 133 134 135 136 137 |
# File 'lib/tins/null.rb', line 129 def null_plus(opts = {}) value = opts[:value] opts[:caller] = caller if respond_to?(:caller_locations, true) opts[:caller_locations] = caller_locations end value.nil? ? Tins::NullPlus.new(opts) : value end |