Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/transparent_nil/object.rb
Instance Method Summary collapse
-
#to_nil_if(condition = :empty) ⇒ nil, self
Returns
nil
if the condition is true. -
#to_nil_unless(condition = :empty) ⇒ nil, self
Returns
nil
if the condition is true.
Instance Method Details
#to_nil_if(condition = :empty) ⇒ nil, self
Returns nil
if the condition is true. Otherwise self
.
17 18 19 20 |
# File 'lib/transparent_nil/object.rb', line 17 def to_nil_if(condition = :empty) return nil if self.respond(condition.to_s + '?') return self end |
#to_nil_unless(condition = :empty) ⇒ nil, self
Returns nil
if the condition is true. Otherwise self
.
25 26 27 28 |
# File 'lib/transparent_nil/object.rb', line 25 def to_nil_unless(condition = :empty) return nil unless self.respond(condition.to_s + '?') return self end |