class MyClass
attr_accessor :name, :surname, :email
end
obj = MyClass.new
hash = {name: 'Ivan', surname: 'Ivanov', email: 'ivan@ivanov.com'}
hash.each do |key, value|
obj.public_send(%Q{#{key}=}, value) if obj.respond_to?(%Q{#{key}=})
end
p obj # => #<MyClass:0x007f9a4c11c478 @name="Ivan", @surname="Ivanov", @email="ivan@ivanov.com">