<_phaul>
gordie: does this^ do what you are after?
pi0 has left #ruby [#ruby]
hiroaki has quit [Ping timeout: 265 seconds]
<gordie>
wow that's quite abstract but seems that it works. Thing is, my reference hash is a JSON schema, so it is not formatted the same way... Would be too easy. Look at the example on stackoverflow
royal_screwup21 has joined #ruby
<CommunistWolf>
&>> { a: 1, b:2 } & {a:1, c:3}
<rubydoc>
stderr: -e:4:in `<main>': undefined method `&' for {:a=>1, :b=>2}:Hash (NoMethodError)... check link for more (https://carc.in/#/r/8p5m)
<CommunistWolf>
hmmmmmmmmm
<baweaver>
They don't have Set operations
<baweaver>
Though I agree I'd like them
<CommunistWolf>
seems like an oversight, yeah
<baweaver>
Coulda sworn someone made an issue of that at one point
<_phaul>
what is the intersection of {a: 1} & {a: 2} ?
<CommunistWolf>
{}
<baweaver>
Yeah that's mostly why
<baweaver>
I can see + and - as naive merge and diff
<baweaver>
{ a: 1 } + { a: 2 } => { a: 2 }
<CommunistWolf>
| is a little tougher
<baweaver>
{ a: 1 } - { a: 2 } => { }
<baweaver>
Kinda like how sum is a naive summation and reduce can do more if you need it later.
<havenwood>
&>> class Hash; %i[& + -].each { |meth| define_method(meth) { |other| to_a.public_send(meth, other.to_a).to_h } } end
<_phaul>
yeah but these don't actually help solving the original question.. as [:a, 1] and [:a, 2] different, but :a should be kept in first hash, because it was a key in the second hash
<baweaver>
To be fair the full problem is much more involved
<baweaver>
and based on JSON schema shenanigans
<gordie>
are you talking about my question or another one ?
ur5us has joined #ruby
<baweaver>
gordie: Yeah, yours
<baweaver>
Not quite as straightforward as hash diffing
<baweaver>
It's more of applying a schema
<gordie>
ok
<gordie>
yeah, not an easy one I guess
<baweaver>
There's also the mixing of string and hash keys
<gordie>
I should admit this is too advanced for me to understand
<baweaver>
There's also whether or not the defaults are applied
<baweaver>
Such that a hypothetical AsubD has a default of 1, isn't present, and gets added to the output with that default value
<gordie>
I was thinking it would have been possible to start from the function I had tweaked to extract the default values (stackoverflow)
<baweaver>
The first thing I would do is make all those keys strings
<baweaver>
otherwise it becomes a juggling game remembering which key is which
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<apotheon>
Is ActsAsTaggableOn still a good tool to use for tagging with ActiveRecord?
<gordie>
and is it not possible to do a function that just iterate the whole hash, and for each key, checks if that same key exists (with an updated path since it is not formatted the same way) in the json schema ?
<baweaver>
I mean possible yes, and json schema probably has things you can riff off of
gordie has quit [Remote host closed the connection]
phaul has joined #ruby
urinal666 has joined #ruby
<urinal666>
hi everyone is ruby good for promoting racism and/or facism?
Dirak has joined #ruby
_phaul has quit [Ping timeout: 255 seconds]
Dirak has quit [Ping timeout: 256 seconds]
Frogging101 has joined #ruby
<apotheon>
I never would have expected that question from someone with a respectable name like "urinal666".
<urinal666>
uh but yes i am trying to make a meaningful conversation by combining random parts of knowledge tha i have gained on other irc channels
<apotheon>
Nothing is "good" for promoting racism or fascism, though perhaps Ruby could be very useful for developing a flashcard application that can help with spelling.
<urinal666>
i have a spelling of a gnat
<urinal666>
but for the objective like uh promoting facism it would be a good idea to to approach poor and mentally ill and or unemployed young people and tel that their problams are because facism is is not implemented
<urinal666>
i mean it would be a valid marketing strategy
<urinal666>
i don't personally support facism or racism
<apotheon>
I'm going to do something more productive than pay further attention to this.
yxhuvud has quit [Ping timeout: 240 seconds]
<baweaver>
!troll urinal666
urinal666 was banned on #ruby by baweaver [*!~ydgfdhh@ncsg05c2eyk7auvrm-2.v6.elisa-mobile.fi]
urinal666 was kicked from #ruby by baweaver [Your behavior is not conducive to the desired environment.]
<baweaver>
Screw right off with that.
nowhereman has quit [Ping timeout: 256 seconds]
Dirak has joined #ruby
royal_screwup21 has quit [Remote host closed the connection]
mokha has quit [Quit: mokha]
Dirak has quit [Ping timeout: 240 seconds]
hiroaki has joined #ruby
royal_screwup21 has joined #ruby
leitz has joined #ruby
davor has quit [Quit: Bye]
davor has joined #ruby
royal_screwup21 has quit [Remote host closed the connection]
d3bug has quit [Quit: Connection closed for inactivity]
<apotheon>
baweaver: good call
troulouliou_dev has quit [Quit: Leaving]
markopasha has quit [Remote host closed the connection]
alfiema__ has joined #ruby
orbyt_ has joined #ruby
Inoperable has joined #ruby
Ven`` has quit [Ping timeout: 255 seconds]
Dirak has joined #ruby
alfiema__ has quit [Ping timeout: 260 seconds]
hiroaki has quit [Ping timeout: 272 seconds]
jmcgnh has quit [Read error: Connection reset by peer]
jmcgnh has joined #ruby
d3bug has joined #ruby
gavlee has joined #ruby
pupsikov has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xco has joined #ruby
taserface has joined #ruby
lucasb has quit [Quit: Connection closed for inactivity]