Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Reducing Code (again)

Reply
Thread Tools

Reducing Code (again)

 
 
Jigar Gosar
Guest
Posts: n/a
 
      03-03-2008
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/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reducing code of ResultSet DTOs Alex Java 4 04-07-2006 04:58 PM
Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code Ralf W. Grosse-Kunstleve Python 16 07-11-2005 09:28 PM
__autoinit__ (Was: Proposal: reducing self.x=x; self.y=y;self.z=z boilerplate code) Ralf W. Grosse-Kunstleve Python 18 07-11-2005 04:01 PM
Reducing Repeated code for arrays JellyBum C Programming 2 05-03-2004 04:12 PM
STL & reducing code bloat Salvador I. Ducros C++ 5 08-04-2003 11:20 PM



Advertisments