Reducing Code (again)

Discussion in 'Ruby' started by Jigar Gosar, Mar 3, 2008.

  1. Jigar Gosar

    Jigar Gosar Guest

    Following is some code that I came up with, for small db processing. I
    have a feeling that I could be further reduced to be more concise.
    Something feels off, I can't put my finger on it. Or maybe for such a
    small task its pretty decent.

    Le me know.
    thanks.


    module MSDB
    DELETE_RESPONSE_TIME_LOG_QUERY = "delete from responsetimelog"

    def copy_results suffix
    transaction do |con|
    con.do "select * into responsetimelog_#{suffix} from
    responsetimelog"
    con.do DELETE_RESPONSE_TIME_LOG_QUERY
    end
    end

    def clear_response_time_log
    transaction do |con|
    con.do DELETE_RESPONSE_TIME_LOG_QUERY
    end
    end

    private
    def transaction
    DBI.connect("...") do |con|
    yield con
    con.commit
    end
    end
    end
    --
    Posted via http://www.ruby-forum.com/.
    Jigar Gosar, Mar 3, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex
    Replies:
    4
    Views:
    412
    john gresh
    Apr 7, 2006
  2. Salvador I. Ducros

    STL & reducing code bloat

    Salvador I. Ducros, Jul 28, 2003, in forum: C++
    Replies:
    5
    Views:
    1,578
    Howard Hinnant
    Aug 5, 2003
  3. JellyBum

    Reducing Repeated code for arrays

    JellyBum, May 3, 2004, in forum: C Programming
    Replies:
    2
    Views:
    267
    Mike Wahler
    May 3, 2004
  4. Ralf W. Grosse-Kunstleve
    Replies:
    16
    Views:
    579
    Lonnie Princehouse
    Jul 11, 2005
  5. Ralf W. Grosse-Kunstleve
    Replies:
    18
    Views:
    593
    Bengt Richter
    Jul 11, 2005
Loading...

Share This Page