[LRUG] Advice: manipulating ActiveRecord objects [newbie]

Graham Ashton graham at effectif.com
Wed Dec 16 05:50:07 PST 2015


On Tue, 15 Dec 2015, at 12:37 PM, Marco Iannone wrote:
> 
> Here are the gists of the responsebuilder
> <https://gist.github.com/marcoi/c96fb66383147d096cf8>and feedbuilder
> <https://gist.github.com/marcoi/f0202a8710700e924db2>(unnecessary stuff
> removed). As I was mentioning the former is used everywhere, the latter
> just here. We can build a bespoke builder.

Hi Marco. `ResponseBuilder` clearly doesn’t do much, so from here onwards let’s ignore it.

If I’ve understood it correctly, only `FeedBuilder` cares what “shape” the `feeds_data` object is.

I wanted to see what `FeedBuilder` actually did with `feeds_data` (i.e. the object encapsulating the ActiveRecord query that you’re trying to optimise), but the gist for `FeedBuilder` doesn’t seem to contain those bits.

I noticed the call to `.data_object_name`, Googled it, and it looks like you’re using Reevoo’s responsible gem to serialize stuff to JSON?

https://github.com/reevoo/responsible

It seems from the README that (to know what `FeedBuilder` is doing with the `feeds_data` variable, and therefore how you could reimplement it to use different objects generated from quicker queries) we'd need to see references (in `FeedBuilder`) to `__data__`.

We’d also need to see the full list of properties (some of them might be delegated directly through to methods on `FeedDetail`, when the properties are defined).

Unless there’s private data in it, I’d suggest you post the whole file. Can you share some of the JSON you want to produce as well?


-- 
Graham Ashton (Founder, Agile Planner)
https://www.agileplannerapp.com | @grahamashton | @agileplanner



More information about the Chat mailing list