Comments (2)
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.
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)
- Proc.new is deprecated HOT 5
- irb: ArgumentError (wrong number of arguments (given 1, expected 0)) HOT 2
- Output of non-empty Hash object fails when using Ruby 3.0 HOT 1
- 1.9 release HOT 12
- Array#uniq is not working on pry with `AwesomePrint.pry!` HOT 5
- Ruby 2.7.0 compatibility HOT 2
- problem with rails and ruby 3.0.0 HOT 2
- ArgumentError (wrong number of arguments (given 1, expected 0)) HOT 4
- undefined method `marshal_dump` for `ActiveModel::Errors` HOT 6
- Getting FrozenError (can't modify frozen String: "false") after upgrading to Ruby 2.7.3 using awesome_print (1.9.2) HOT 5
- Plain Ruby Objects are not formatted properly HOT 2
- Hi, can I put `.aprc` under ~/.config/awesome_print/aprc?
- `.pry!` does nothing in rails console
- Don't override/monkey patch `String` class HOT 3
- object_id option not operating as expected
- Maintained fork: amazing-print/amazing_print
- Pretty print object as executable code
- ap.awesome_sequel_dataset(ds) Arguments Error
- ActiveRecord methods with `ap` displays nothing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from awesome_print.