Module: NoConditionals::Truthiness

Defined in:
lib/no_conditionals.rb

Overview

Mixin for truthy behavior

Instance Method Summary collapse

Instance Method Details

#hence {|_self| ... } ⇒ Object

evaluates a block, passes object

Yields:

  • (_self)

Yield Parameters:



10
11
12
# File 'lib/no_conditionals.rb', line 10

def hence
  yield self
end

#maybe(so, maybe: self) ⇒ Object

just returns first parameter (so), ignores optional second parameter (maybe)



20
21
22
# File 'lib/no_conditionals.rb', line 20

def maybe so, maybe: self
  so
end

#maybe!(so, maybe: -> {}) ⇒ Object

calls first parameter (so)



25
26
27
# File 'lib/no_conditionals.rb', line 25

def maybe! so, maybe: -> {}
  so.call
end

#otherwiseObject

just returns object, ignores block



15
16
17
# File 'lib/no_conditionals.rb', line 15

def otherwise
  self
end