title: Ruby inheritance of class and method in JDBC connection string
body: <p>I have the following code snippet that generates a JDBC connection string for various databases. In this case, Dash DB and IBM DB2. The following is the structure of the code I use to generate my connection string in DB2.</p>
  
  <pre><code>def connection_creation_information
    @connection_creation_information ||= Class.new(JDBCConnectionCreationInformation) do
  
      private
  
      def connection_string_primary_params(options)
        params = []
  
        params &lt;&lt; "currentSchema=#{options[:schema] || options[:username]}"
  
        params &lt;&lt; options[:jdbc_additional_params] if options[:jdbc_additional_params]
  
        params
      end
  
      def connection_string_scheme
        'db2'
      end
  
      def connection_string_params(options)
        super + ';'
      end
  
      def primary_param_separator
        ';'
      end
  
      def base_separator
        ':'
      end
    end.new
  end
  </code></pre>
  
  <p>Now, DashDB uses <code>defaultSchema</code> to define the default schema, while in DB2, it uses <code>currentSchema</code>. I am trying to minimize redundant code as much as possible, so right now, Dash DB's code inherits from DB2 using <code>class HTDialectDashDB &lt; HTDialectDB2</code> and override the one line/method that matters -- <code>connection_string_primary_params()</code></p>
  
  <p>In my Dash DB class, I am doing the following:</p>
  
  <pre><code>def connection_creation_information
    @connection_creation_information ||= Class.new(JDBCConnectionCreationInformation) do
  
      private
  
      def connection_string_primary_params(options)
        params = []
  
        params &lt;&lt; "defaultSchema=#{options[:schema] || options[:username]}"
  
        params &lt;&lt; options[:jdbc_additional_params] if options[:jdbc_additional_params]
  
        params
      end
  
    end.new
  end
  </code></pre>
  
  <p>However, errors are being thrown that I must implement the four other methods described in the DB2 code, which I want to avoid, because it's just redundant code. </p>
  
  <p>What can I do in this case? </p>