Code Monkey home page Code Monkey logo

Comments (5)

elithecho avatar elithecho commented on June 29, 2024

Ok, looks like I may have misread it!

The constructor of Surrealist::Serializer takes two arguments: serializable model (or collection) and a context hash. So if there is an object that is not coupled to serializable model but it is still necessary for constructing JSON, you can pass it to constructor as a hash. It will be available in the serializer in the context hash.

I'm just wondering here, since using Surrealist::Serializer is to decouple the model from serializer, why can't we receive the collection raw, and use the base class itself to serialize the collection without needing to wrap them in a Serializable model?

We can use a raw object Serializers::Impression.new(Impression.new) but unable to use Serializers::Impression.new([Impression.new]).new

from surrealist.

kolasss avatar kolasss commented on June 29, 2024

@choonggg try hash = Serializers::Impression.new([Impression.new]).build_schema
JSON.dump hash

from surrealist.

elithecho avatar elithecho commented on June 29, 2024

Thanks @kolasss, it works. Just wondering if it can be done automatically or with another method without going through JSON/Oj dumping.

from surrealist.

nesaulov avatar nesaulov commented on June 29, 2024

Hey @choonggg thank you for the issue, I will look into this during the week

from surrealist.

elithecho avatar elithecho commented on June 29, 2024

great! @nesaulov thank you.

from surrealist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.