Skip to content

Ruby: Model ActiveModel#serializable_hash#12253

Draft
hmac wants to merge 3 commits into
github:mainfrom
hmac:serializable-hash
Draft

Ruby: Model ActiveModel#serializable_hash#12253
hmac wants to merge 3 commits into
github:mainfrom
hmac:serializable-hash

Conversation

@hmac
Copy link
Copy Markdown
Contributor

@hmac hmac commented Feb 19, 2023

This doesn't yet work - we need to model flow from ActiveRecord-like
fields to elements in the return hash.

This method returns a hash of the attributes of the receiver.
@hmac
Copy link
Copy Markdown
Contributor Author

hmac commented Feb 19, 2023

Apologies if you got pinged by this - I briefly rebased against an old version of main.

|
input = "Argument[self].Field[" + field + "]" and
output = "ReturnValue.Element[\"" + name + "\"]" and
preservesValue = true
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hvitved do you have any recommendations on how to express this in a way that doesn't generate tons of new dataflow steps?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is an easy fix. At least, we will only be generating one read-field-store-element chain per field in the DB inside the synthesized callable, so maybe it is not too bad in practice. Alternatively, we could have the much less precise version, as you suggest:

input = "Argument[self].Field[any]" and
output = "ReturnValue.Element[?]"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - I'll run a few more DCA runs and we can make a decision on whether the performance hit is too much. I think Field[any] is not a syntax we support (yet), but I will double check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Field[any] is not a syntax we support (yet)

Yeah, we don't support it yet, but should be easy to add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants