title: Ruby: Dynamically build member name of a struct?
body: <p>I have two questions.</p>
  
  <p>1) I need to create a dynamic structure, whose members are driven through an array.
  For ex:</p>
  
  <pre><code>    members = [:a, :b]
      Config  = Struct.new(members) #=&gt; Struct.new(:a, :b)
      FlatConfig = Struct.new(members) #=&gt; Struct.new(:a, :b)
      config = Config.new()
      flat = FlatConfig.new()
  </code></pre>
  
  <p>After some days, If I need to add another member to these struct, then all I need to do is add a member in that members array (memebers = [:a, :b, :c]) and I don't need to tough the code further. Thus I am asking this. How to achieve this?</p>
  
  <p>2) Now I need to build the values of flat Struct members by means of doing some manipulation on config struct member values. 
  For eg:</p>
  
  <pre><code>    config.each{|configMember|
        result = configMember.collect{|c| someArray.collect{|s| s + '--' + y}}
        flat[":#{cofigMember}"] = result #=&gt; Intent is to store result in same member as iterated through  config struct.
      }
  </code></pre>
  
  <p>How to achieve (1) and (2)?</p>
  
  <p>Thanks in advance.</p>