If I have this class:

class A
  attr_accessor :b,:c,:d
end

and this code:

a = A.new
h = {"b"=>10,"c"=>20,"d"=>30}

is it possible to initialize the object directly from the hash, without me needing to go over each pair and call instance_variable_set? Something like:

a = A.new(h)

which should cause each instance variable to be initialized to the one that has the same name in the hash.

Edit
Report