how to convert an array of hash into object : I am trying to convert following array of hash into an object.

    data = {
        k: [ {id: 'abc'}, {id: 'bcd'}, {id: 'cde'} ]
        # o: { [{id: 'acd'}, {id: 'opu'}], id: 'qiu' }
        }

This is what i have done so far.

    class Test
      def initialize(sample)
        sample.each do |k,v|
          # self.instance_variable_set("@#{k}", v.is_a?(Hash) ? Test.new(v) : v)
          self.instance_variable_set("@#{k}", v.is_a?(Array) ? Test.new(v.map do |v| v[:id] end) : v)
        end
      end
    end

    test = Test.new(data)

It returns `#<Test:0x00005628978c1e30 @k=#<Test:0x00005628978c1d90 @abc=nil, @bcd=nil, @cde=nil>>` but what i am trying to get is this

`#<Test:0x00005628978c1e30 @k=['abc', 'bcd', 'cde']>>`

Also trying to convert the hash (commented in data) into object.

Does anyone know how can i achieve this?

Any help is appreciated. Thanks.