Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Reducing Code (again
Jigar Gosar
3/3/2008 11:34:00 AM
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-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Reducing Code (again
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password