 <p>Your question raises some interesting issues. I will try to explain how you can fix it, but, as @Uri mentions, there may be better ways to address your problem.</p> <p>I've assumed <code>@tranfee</code> is to be set equal to the first value in the hash whose key begins with <code>"tran"</code> and that <code>@rate</code> is to be set equal to the first value in the hash whose key begins with <code>"rate"</code>. If that interpretation is not correct, please let me know.</p> <p>Note that I've put <code>initialize</code> in the <code>PaymentType</code> module in a class (<code>Papa</code>) and made <code>TranFee</code> and <code>Rate</code> subclasses. That's the only way you can use <code>super</code> within <code>initialize</code> in the subclasses of that class.</p> <p><strong>Code</strong></p> <pre><code>class Transaction attr_reader :tranfee, :rate def initialize(hash={}) o = PaymentType::TranFee.new(hash) @tranfee = o.instance_variable_get(o.instance_variables.first) o = PaymentType::Rate.new(hash) @rate = o.instance_variable_get(o.instance_variables.first) end end </code></pre> <p>.</p> <pre><code>module PaymentType class Papa def initialize(hash, prefix) key, value = hash.find { |key,value| key.start_with?(prefix) &amp;&amp; value } (raise ArgumentError, "No key beginning with #{prefix}") unless key instance_variable_set("@#{key}", value) self.class.singleton_class.class_eval { attr_reader key } end end class TranFee &lt; Papa def initialize(hash) super hash, "tran" end end class Rate &lt; Papa def initialize(hash) super hash, "rate" end end end </code></pre> <p>I believe the method <a href="http://ruby-doc.org/core-2.1.1/Object.html#method-i-singleton_class" rel="nofollow">Object#singleton_class</a> has been available since Ruby 1.9.3.</p> <p><strong>Example</strong></p> <pre><code>reg_debit = {"name" =&gt; "reg_debit", "rate_base" =&gt; 0.0005, "tran_fee" =&gt; 0.21, "rate_basis_points" =&gt; 0.002, "tran_auth_fee" =&gt; 0.10} a = Transaction.new reg_debit p Transaction.instance_methods(false) #=&gt; [:tranfee, :rate] p a.instance_variables #=&gt; [:@tranfee, :@rate] p a.tranfee #=&gt; 0.21 p a.rate #=&gt; 0.0005 </code></pre>