I need to get the superset of instance variables available across all objects of a class, i.e. [@a,@b,@c]
below:
class Test
attr_accessor :a,:b,:c
end
obj = Test.new
obj.a = 10
obj2 = Test.new
obj2.b = 20
obj.instance_variables # => [@a]
obj2.instance_variable # => [@b]
The need over here is to get a list containing [@a,@b,@c]
. An alternative is to look for obj.class.instance_methods
. However, it will also return other instance methods present in class.
How this can be achieved?