Giter Site home page Giter Site logo

Comments (2)

senhalil avatar senhalil commented on September 28, 2024

Similar situation here. @sam0x17 we had a similar issue with to_json and the way we handled it was "marking" the fields as :id_only, :none (or by default full object) that way we managed to have "minimal" serialised objects that can be re-created.

However, even if we already have custom :to_s, :inspect and :as_json methods when we call ap on the object, it by-passes these custom functions but if I do ap myObject.inspect or ap myObject.as_json, everything works as expected -- i.e., only the "selected" fields are shown on the screen.

What serialiser ap uses by default? Is there a way to set the object serializer in ap?

from awesome_print.

senhalil avatar senhalil commented on September 28, 2024

Overloading the :to_hash as well did the trick!

@sam0x17 in case it might be of help to you, we define an option :as_json for the members of a class -- for example each route has a vehicle but we do not want to dump nor display the details of the vehicle object inside route dump so we mark it as as_json: :id here and we override the :as_json as such so that it can dump full object, just id, or nothing at all.

from awesome_print.

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.