I have this module I am using to do updates on a row in a table that is
getting very redundant. I was trying to figure out if I can reduce this by
using some type of variable in place of the column name.
So for example my module has about 10 methods like this (simplified, are
some other things going on, but reducing for this question.
def self.set_thing_x(id, value, notes)
db[:my_job]
.where(job_id: id)
.update(stage: notes, thing_x: value)
end
def self.set_thing_y(id, value, notes)
db[:my_job]
.where(job_id: id)
.update(stage: notes, thing_y: value)
end
The only thing that is really different, is the name of the column. I know
the name of the column, hence I picked the right method name.
This must be simple, I am just missing it.
FYI db in the above code is basically a Sequel::Postgres::Database object
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/2e4e43ae-fec4-404e-8a49-2cb930c5fcba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.