Revisiting this, is it possible to store state along with a dataset in 5.*? 
How could I accomplish that? Thanks


On Sunday, 22 October 2017 11:32:31 UTC-10, Kawika wrote:
>
> Thanks, I didn't know about with_extend that gets me a little further in 
> understanding. I take it that modules that Datasets include/extend are no 
> longer supposed to modify their own instance variables, etc, used for house 
> keeping.
>
> I think I'll need to change things up a bit and perhaps do everything on 
> Sequel::Model instead of Dataset
>
> On Thursday, 19 October 2017 16:10:38 UTC-10, Jeremy Evans wrote:
>>
>> On Thursday, October 19, 2017 at 6:41:10 PM UTC-7, Kawika wrote:
>>>
>>> Prior to 5.0 we were able to mutate datasets which I took advantage of 
>>> for a custom paging gem to pass data along to a view. Basically at some 
>>> point doing the following when querying
>>>
>>> ds.extend(MyModule)
>>>
>>> Where ds is a Sequel::Dataset after however many filter chains. Before I 
>>> re-author my approach (which was generalized for Sequel and ActiveRecord, 
>>> so I kind of like it as-is) is there an alternative/recommended way mutute 
>>> datasets or otherwise hitch data to a dataset?
>>>
>>
>> No, mutating of datasets is no longer supported.  You can kind of fake it 
>> in ruby <2.4, but on ruby 2.4+ they really are frozen.  If you just want to 
>> apply a module to a dataset, you can do:
>>
>>   ds = ds.with_extend(MyModule)
>>
>> This will not work if your API takes a dataset/relation and does not 
>> return a value.  You'll need to change your API to return the 
>> dataset/relation to use in that case.
>>
>> 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 https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to