dhruvasagar has quit [Remote host closed the connection]
dhruvasa` has quit [Remote host closed the connection]
dhruvasagar has joined #ruby
dhruvasa` has joined #ruby
dhruvasa` has quit [Read error: Connection reset by peer]
dhruvasagar has quit [Read error: Connection reset by peer]
hiddenman_ has joined #ruby
lunarkitty is now known as [lunarkitty]
[lunarkitty] is now known as {[pyra]}
{[pyra]} is now known as {[`
{[` is now known as ]
] is now known as Guest3814
Guest3814 is now known as [pyra]
[pyra] is now known as lunarkitty
dhruvasagar has joined #ruby
dhruvasagar has quit [Remote host closed the connection]
dhruvasagar has joined #ruby
dhruvasagar has quit [Remote host closed the connection]
dhruvasagar has joined #ruby
dhruvasagar has quit [Remote host closed the connection]
dhruvasagar has joined #ruby
dviola has quit [Ping timeout: 260 seconds]
Linux_Kerio has quit [Ping timeout: 248 seconds]
dhruvasagar has quit [Ping timeout: 252 seconds]
dhruvasagar has joined #ruby
rvalue- has joined #ruby
rvalue has quit [Ping timeout: 248 seconds]
lunarkitty has quit [Remote host closed the connection]
diego has joined #ruby
diego is now known as Guest4853
rvalue- is now known as rvalue
donofrio has joined #ruby
Awoobis is now known as gAy_Dragon
dhruvasagar has quit [Remote host closed the connection]
Linux_Kerio has joined #ruby
Linux_Kerio has quit [Read error: Connection reset by peer]
zubov has joined #ruby
zubov has quit [Quit: Konversation terminated!]
<vvn>
when requiring 'json|yaml', objects automatically inherit a #to_json|yaml method, how does that work? I can't find the relevant documentation for this mechanism
user71 has joined #ruby
user71 has quit [Max SendQ exceeded]
user71 has joined #ruby
<constxd>
vvn: u just define that shit on Object bro
<vvn>
how does a custom class implement #to_json conditionally whether json is required or not?
Linux_Kerio has joined #ruby
donofrio has quit [Ping timeout: 260 seconds]
hwpplayer1 has joined #ruby
<havenwood5>
vvn: You usually define #as_json that returns a Hash then a #to_json that calls #to_json on your #as_json Hash.
<havenwood>
Then define a self.json_create and use JSON.unsafe_load or JSON.load(create_additions: true), neither of which is safe for untrusted input.
<havenwood>
The convention of using single letter keys, like 't' and 's', is just to save payload weight. You can use 'toppings' and 'syrup' if you prefer.
<havenwood>
vvn: As for what to do whether JSON is required or not, 🤷. Options include an autoload of JSON to lazily load it when #to_json is called, or only conditionally defining your JSON methods behind an `if defined?(JSON)`.
<havenwood>
Or having your JSON feature be an addition, and have an explicit load of your feature that also explicitly loads JSON.