Module: DR::CoreExt::Object

Defined in:
lib/dr/ruby_ext/core_modules.rb

Instance Method Summary collapse

Instance Method Details

#and_this(&b) ⇒ Object

simulate the Maybe monad



216
217
218
# File 'lib/dr/ruby_ext/core_modules.rb', line 216

def and_this(&b)
  nil? ? nil : this(&b)
end

#thisObject

in ruby 2.2, 'Object#itself' only returns self



211
212
213
214
# File 'lib/dr/ruby_ext/core_modules.rb', line 211

def this
  return yield(self) if block_given?
  return self
end