Class: Object

Inherits:
BasicObject
Defined in:
lib/babushka/core_patches/try.rb,
lib/babushka/core_patches/object.rb

Overview

The implementation of #try as found in activesupport:

lib/active_support/core_ext/object/try.rb

Try is just a nil-swallowing send, which means return nil when called on nil and just send like normal when called on any other object.

Instance Method Summary collapse

Instance Method Details

#metaclassObject

Return this object's metaclass; i.e. the value of self within a 'class << self' block.



9
10
11
12
# File 'lib/babushka/core_patches/object.rb', line 9

def metaclass
  Babushka::LogHelpers.deprecated! '2017-09-01', instead: '`class << self; self end`'
  class << self; self end
end

#tappObject

Return self unmodified after logging the output of #inspect, along with the point at which tapp was called.



16
17
18
19
# File 'lib/babushka/core_patches/object.rb', line 16

def tapp
  Babushka::LogHelpers.deprecated! '2017-09-01'
  tap { STDOUT.puts "#{File.basename caller[2]}: #{self.inspect}" }
end

#try(*args) ⇒ Object



8
9
10
11
# File 'lib/babushka/core_patches/try.rb', line 8

def try(*args)
  Babushka::LogHelpers.deprecated! '2017-09-01'
  __send__(*args)
end