Skip to content

Instantly share code, notes, and snippets.

@amolpujari
Created September 13, 2019 07:28
Show Gist options
  • Save amolpujari/ad1f4b61a3ffc50ab4e90dfe9b0dbac1 to your computer and use it in GitHub Desktop.
Save amolpujari/ad1f4b61a3ffc50ab4e90dfe9b0dbac1 to your computer and use it in GitHub Desktop.
inspect ruby object in private
Object.class_eval do
def private_inspect
memo = {}
self.instance_variables.inject(memo) do |memo, var|
memo[var] = self.instance_variable_get(var).to_s
memo
end
except = [:__, :_, :_ex_, :_pry_, :_out_, :_in_, :_dir_, :_file_]
(self.__binding__.local_variables - except).inject(memo) do |memo, var|
memo[var] = self.__binding__.local_variable_get(var).to_s
memo
end
memo
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment