Here's an example:

Let's say I have a user model (class: User) with a unique email field.

Multiple datasets are capable of pulling the same model instances. User[1] 
and User[email: '[email protected]'] can return the same instance but use 
two different datasets. So what I'd want to be able to determine on a model 
instance is, what was the specific dataset that created it. It might even 
be a collection, like User.all (which, if I'm not mistaken, is the dataset 
returned by User.dataset) or even something nonspecific like User.first. 
user_instance.this is most likely equal to the dataset User[<pk>] uses to 
get the instance.

I did end up coding this because I couldn't find anything that seemed to 
fit the bill, but like I said, me missing something isn't exactly uncommon. 
Haha.

On Wednesday, September 4, 2013 2:09:45 PM UTC-7, Jeremy Evans wrote:
>
> On Wednesday, September 4, 2013 8:52:36 AM UTC-7, Joshua Hansen wrote:
>>
>> I've checked the docs, but missing a feature and reimplementing it in a 
>> plugin has happened to me at least twice when following this procedure so I 
>> figured I'd ask first:
>>
>> Do models have any knowledge of the dataset that created them? For 
>> reasons related to a caching plugin I'm modifying, it would be useful if a 
>> model knew about the dataset. I know a model can call "this" which brings 
>> up the naked dataset for just that model, but that's not always what I want.
>>
>> Does this feature exist?
>>
>
> Assuming you want the dataset for the class of the model instance, you can 
> get the dataset via model_instance.model.dataset.  If you want something 
> else, please be more specific.
>
> Thanks,
> Jeremy
>

-- 
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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to