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. Advertisements

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:
    555
    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,886
    Howard Hinnant
    Aug 5, 2003
  3. JellyBum

    Reducing Repeated code for arrays

    JellyBum, May 3, 2004, in forum: C Programming
    Replies:
    2
    Views:
    336
    Mike Wahler
    May 3, 2004
  4. Ralf W. Grosse-Kunstleve
    Replies:
    16
    Views:
    827
    Lonnie Princehouse
    Jul 11, 2005
  5. Ralf W. Grosse-Kunstleve
    Replies:
    18
    Views:
    934
    Bengt Richter
    Jul 11, 2005
  6. Ralf W. Grosse-Kunstleve
    Replies:
    2
    Views:
    654
    Dan Sommers
    Jul 12, 2005
  7. falcon
    Replies:
    0
    Views:
    565
    falcon
    Jul 31, 2005
  8. Lance Hoffmeyer

    Newbie help looping/reducing code

    Lance Hoffmeyer, Feb 19, 2007, in forum: Python
    Replies:
    3
    Views:
    446
    Cameron Laird
    Feb 20, 2007
Loading...