Module: DR::CoreExt::Object

Defined in:
lib/drain/ruby_ext/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#and_this(&b) ⇒ Object

simulate the Maybe monad



180
181
182
# File 'lib/drain/ruby_ext/core_ext.rb', line 180

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

#thisObject

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



175
176
177
178
# File 'lib/drain/ruby_ext/core_ext.rb', line 175

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