Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IvarTracer for tracing ivar changes #16

Merged
merged 2 commits into from
Jun 1, 2023
Merged

Add IvarTracer for tracing ivar changes #16

merged 2 commits into from
Jun 1, 2023

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Jun 1, 2023

This idea was proposed by and implemented with @KaanOzkan.

IvarTracer will print traces when the target object' target attribute is being reassigned.

require "tracer"

class Cat
  attr_accessor :name
end

cat = Cat.new

tracer = IvarTracer.new(cat, :@name)
tracer.start do
  cat.name = "Kitty" #=> #depth:3 Cat#name= sets @name = "Kitty" at test.rb:11
  cat.instance_variable_set(:@name, "Ketty") #=> #depth:3 Kernel#instance_variable_set sets @name = "Ketty" at test.rb:12
end

@st0012 st0012 added the enhancement New feature or request label Jun 1, 2023
@st0012 st0012 merged commit e96093f into master Jun 1, 2023
@st0012 st0012 deleted the ivar-tracer branch June 1, 2023 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

1 participant