I have a abstract BaseModel class which includes some common code shared
among all models. Every model I have inherits it.
BaseModel = Class.new(Sequel::Model) do
... code ..
end
One of my models needs to set its backing table dynamically upon each
request on my Sinatra App. My first idea was to create a class method to
configure the dataset before actually using it, but I realised this
approach is not thread safe.
class Foo < BaseModel
def self.config(table_name)
set_dataset(table_name)
end
... code ...
end
The I thought about creating the model dynamically on each call and use
Foo.klass to access it.
class Foo
def initialize(table_name)
super
@klass = Class.new(BaseModel) do
set_dataset table_name
... code ...
end
end
end
Which is the recommended way to accomplish what I intend to do?
Thanks!
--
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.
For more options, visit https://groups.google.com/d/optout.