Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return records parsed into proper objects instead of hashes #5

Open
mackuba opened this issue Jun 15, 2023 · 2 comments
Open

Return records parsed into proper objects instead of hashes #5

mackuba opened this issue Jun 15, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@mackuba
Copy link
Owner

mackuba commented Jun 15, 2023

No description provided.

@kawayuta
Copy link

ASAP pls

@mackuba
Copy link
Owner Author

mackuba commented Jul 20, 2023

Hey, I don't think I will be changing this soon, to be honest… My focus right now is on performance - the websocket library I've used was struggling to keep up with the stream on some days with more traffic. I'm working on a new version with a different library on the faye branch, and then I want to optimize it some more.

Just adding some records built from JSON would be easy, but I don't know yet how to do it "right" in a way that I will be happy with. Ideally it should be somehow building record classes from the "lexicon" definitions to make it more universal. But how much of the lexicon should I cover? How to name the records? To what degree should it be automatic? Should this be in a separate library? Should I share the code with other Ruby libraries for AtProto? I was thinking about this just yesterday, but I don't have answers right now and it's not a priority. And I don't want to add a new quickly done API now and change it later.

If you want a more friendly API right now with accessing properties using dots instead of [''], you can use e.g. the Mash thing from Hashie https://github.com/hashie/hashie#mash, or do something like this using OpenStruct:

JSON.parse(op.raw_record, object_class: OpenStruct)

This builds a nested OpenStruct from JSON which can then let you do something like: record.embed.image.alt.

@mackuba mackuba added the enhancement New feature or request label Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants