<ytti>
or test for the actual object you put there
<ytti>
s.include? Person.new(name)
<TzilTzal>
I don't want to use a hash since that duplicates the name
<ytti>
either you use find or you test for the actual object you put there
<ytti>
dunno what else to tell you
<ytti>
let me try this otherway around
<ytti>
if ruby would do magically what ever you wish it would do, what code would work?
<ytti>
because my imagination fails to see any other opportunities
lovelove has quit [Quit: Connection closed for inactivity]
cnsvc has joined #ruby
roadie has quit [Remote host closed the connection]
cnsvc has quit [Ping timeout: 240 seconds]
d3bug has quit [Quit: Connection closed for inactivity]
<pyrmont>
TzilTzal: This is Ruby. You can simply patch Set to do what you want. Monkey patching like that has issues but if you understand what they are you can make it do what you want.
<pyrmont>
TZilTzal: Alternatively, you can create a new object that inherits from Set and overriding the #include? method and simply use your new Set-like collection object instead of Set.
<pyrmont>
*overrides
paraxial has joined #ruby
paraxial has quit [Client Quit]
paraxial has joined #ruby
royal_screwup21 has joined #ruby
chalkmonster has joined #ruby
p3ps1 has quit [Ping timeout: 258 seconds]
TzilTzal has quit [Quit: Leaving.]
burningserenity has joined #ruby
drincruz_ has joined #ruby
royal_screwup21 has quit [Remote host closed the connection]
p3ps1 has joined #ruby
cnsvc has joined #ruby
<ytti>
pyrmont, that implies there is something that can be added
<ytti>
pyrmont, to me it's not obvious how Set could perform better
<ytti>
which is why i'd like to see the dream code, what it would do in his ideal world
<ytti>
my imagination fails me
cnsvc has quit [Ping timeout: 240 seconds]
drincruz_ has quit [Ping timeout: 256 seconds]
<pyrmont>
Perhaps I'm missing it but can't you just have #include? check the #name getter of each of the objects inside it?
<pyrmont>
Seems pretty straightforward.
<pyrmont>
TzilTzal said they wanted to be able to send the name of the Person and use that to fetch the item from the Set. What's there to imagine?
vondruch_ has joined #ruby
burningserenity has quit [Ping timeout: 258 seconds]
vondruch has quit [Ping timeout: 255 seconds]
vondruch_ is now known as vondruch
<ytti>
pyrmont, but that is what the find did
<ytti>
pyrmont, and he didn't want the find because reasons
<ytti>
12:51 < TzilTzal> That probably defies the whole purpose of using a Set...
<ytti>
so he doesn't want to compare the iterms getter method
<ytti>
and he doesn't waqnt to give thet set Person.new(name)
<pyrmont>
It seems a strength to me of Ruby that you can solve problems in multiple ways. Whatever fits the way they think.
<ytti>
so what is there to do?
<ytti>
yes but my issue is, i can't see any other way
<ytti>
but to löook at the getter or create the object
<ytti>
and OP wants something else, and my imagination doesn't stretch to understand what something else could be
<pyrmont>
Your solution exposes the implementation to the user of the collection.
<ytti>
that wasn't his complaint
<pyrmont>
If you override #include? you arguably have a more semantically clear method that might be more ergonomic. Behind the scenes, it can use #find but you don't need to make that clear to the user of the API.
<ytti>
his complain was that the defies the purpose of using set
<ytti>
implying he should just check for existence
RougeR has quit [Remote host closed the connection]
<ytti>
not iterate the list
<ytti>
and your proposal also iterates
<ytti>
so if you don't want to iterate and you don't want to check for the actual object
<ytti>
what other venues are there?
RougeR has joined #ruby
<pyrmont>
Well, no, I said you could override #include? I didn't say what the implementation should be. You could implement it with a Set of names that sits inside the Set. You could
markoong has quit [Ping timeout: 260 seconds]
<pyrmont>
…implement it with an internal Hash.
<ytti>
14:03 < pyrmont> Perhaps I'm missing it but can't you just have #include? check the #name getter of each of the objects inside it?
<ytti>
that is iteration
<pyrmont>
But since he or she is gone it's probably not worth worrying about at this point.
<ytti>
which is what OP didn't want
<pyrmont>
Sorry, you're right. I did eventually suggest that. Initially I said: <pyrmont> TzilTzal: This is Ruby. You can simply patch Set to do what you want. Monkey patching like that has issues but if you understand what they are you can make it do what you want.
<ytti>
what ever you do, you either iterate or you check for the object itself
<ytti>
i proposed both #find to iterate and Person.new(name) for the object itself, neither was acceptable
<ytti>
which i believe leaves us with solution space of 0
<pyrmont>
👍
<ytti>
and seeing the dream code would possibly add clarity
cnsvc has joined #ruby
stryek has joined #ruby
jcalla has quit [Ping timeout: 265 seconds]
cnsvc has quit [Ping timeout: 240 seconds]
burningserenity has joined #ruby
duderonomy has joined #ruby
leitz has joined #ruby
drincruz_ has joined #ruby
margeas has joined #ruby
markong has quit [Ping timeout: 255 seconds]
drincruz_ has quit [Ping timeout: 240 seconds]
P1RATEZ has joined #ruby
RougeR has quit [Remote host closed the connection]
RougeR has joined #ruby
postmodern has quit [Read error: Connection reset by peer]
postmodern has joined #ruby
stdedos has quit [Remote host closed the connection]
infinityfye has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
ua has quit [Read error: Connection reset by peer]
ua has joined #ruby
jcalla has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
lucasb has joined #ruby
cnsvc has joined #ruby
Bounga has joined #ruby
cnsvc has quit [Ping timeout: 240 seconds]
alexherbo2 has quit [Remote host closed the connection]
zlogan has quit [Remote host closed the connection]
zlogan has joined #ruby
drincruz_ has joined #ruby
Bounga has quit [Remote host closed the connection]
pelegreno___ has quit [Ping timeout: 265 seconds]
cnsvc has joined #ruby
Dirak has joined #ruby
hutch has joined #ruby
cnsvc has quit [Ping timeout: 240 seconds]
fercell has quit [Quit: WeeChat 2.7.1]
Dirak has quit [Ping timeout: 240 seconds]
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
cnsvc has joined #ruby
<dreamreal>
Has anyone here gotten bearer authentication working with Net::HTTP?
<dreamreal>
I'm building the request properly, I think - debugger shows the headers and all - and it matches what Postman is showing as working, but I'm not getting a proper response
<dreamreal>
I got httparty to work, net::http still fails, something about the headers I THINK
mre- has joined #ruby
cnsvc has joined #ruby
<al2o3-cr>
dreamreal: show how you are doing it with net/http.
P1RATEZ has quit [Remote host closed the connection]
<dreamreal>
pretty simple: get the http reference (Net::HTTP.new(endpoint.host, endpoint.port), then getting the request, setting the headers with request["Authorization"]="Bearer #{@api_key}", then http.request(request)
TheBrayn has quit [Quit: poof]
cthu| has joined #ruby
<dreamreal>
the response comes back as a 400 - which is weird, because it SHOULD be a 401 - but the authorization header IS being set (but with "authorization" as a key and not "Authorization")
infinityfye has quit [Ping timeout: 258 seconds]
alexherbo2 has quit [Remote host closed the connection]
<al2o3-cr>
dreamreal: that code you shown should work. wonder why it's coming back as a bad request.
royal_screwup21 has quit [Remote host closed the connection]
<al2o3-cr>
i missed to closing brace but i updated it.
RougeR has quit [Remote host closed the connection]
RougeR has joined #ruby
robenkleene has joined #ruby
<dreamreal>
well, it's working with httparty now - I'd rather not revert to test
<dreamreal>
but I truly appreciate the advice
<szqdsegrhrdgdrg>
dreamreal could You help me ? It's about Rails
<al2o3-cr>
dreamreal: i was just curious to why it was failing. dreamreal good luck.
gbt1988 has joined #ruby
<dreamreal>
szqdsegrhrdgdrg: I wish I could but I think I royally suck at ruby
<dreamreal>
al2o3-cr: honestly, me too but I'm already behind on an integration effort :/
<al2o3-cr>
dreamreal: np.
<szqdsegrhrdgdrg>
dreamreal No proble
<szqdsegrhrdgdrg>
problem
<al2o3-cr>
szqdsegrhrdgdrg: have you asked in #rubyonrails maybe they can help you?
<szqdsegrhrdgdrg>
al2o3-cr Yes, but it's seem they are not presents
<al2o3-cr>
just hold on here until someone knows. there is a few people who know rails here.
sdu has quit [Remote host closed the connection]
<adam12>
szqdsegrhrdgdrg: Are you using webpacker? What version of Rails?
<szqdsegrhrdgdrg>
Yes
<szqdsegrhrdgdrg>
It's : Rails 6.0.2.1
<szqdsegrhrdgdrg>
My issue is that I can't call a function from my "test.js"
<szqdsegrhrdgdrg>
in my layout file I have : " <%= javascript_pack_tag 'test', 'data-turbolinks-track': 'reload' %>"
<adam12>
szqdsegrhrdgdrg: Old versions of Rails used to include a Sprockets statement which required all javascript. You always loaded the one file (application.js) but that would load the rest.
<adam12>
szqdsegrhrdgdrg: Inside your application.js, you're probably going to want to `import "test.js"`
<adam12>
I don't use Rails or Webpack so probably won't be much help other than that.
yxhuvud has joined #ruby
gbt1988 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
Dirak has joined #ruby
<szqdsegrhrdgdrg>
I finally fix the issue
<szqdsegrhrdgdrg>
in the js file, instead of using function declaration, you should use function expression
<szqdsegrhrdgdrg>
Thanks
Dirak has quit [Ping timeout: 258 seconds]
thecoffemaker has quit [Read error: Connection reset by peer]
zlogan has quit [Read error: Connection reset by peer]
sergioro has joined #ruby
hiroaki has joined #ruby
dinfuehr has quit [Ping timeout: 256 seconds]
dinfuehr has joined #ruby
dinfuehr has quit [Ping timeout: 240 seconds]
dinfuehr has joined #ruby
fanta1 has quit [Quit: fanta1]
akem has joined #ruby
banisterfiend has joined #ruby
alfiemax has joined #ruby
cnsvc has quit [Ping timeout: 240 seconds]
RougeRR has joined #ruby
RougeR has quit [Read error: Connection reset by peer]
Dirak has joined #ruby
Dirak has quit [Read error: Connection reset by peer]
x0f_ has quit [Ping timeout: 255 seconds]
x0f has joined #ruby
cnsvc has joined #ruby
sauvin has quit [Read error: Connection reset by peer]
drincruz_ is now known as drincruz
cnsvc has quit [Ping timeout: 240 seconds]
<dreamreal>
This may be (yet another) stupid question... but if I'm trying to create a hash with strings as keys, what's the right way to do this? Like, I literally want a hash of "Id" => id, "Name" => name....
ellcs has joined #ruby
<leftylink>
indeed, hashes can have strings as keys. I sense there must be something I'm missing to this question.
ellcs has quit [Ping timeout: 240 seconds]
<dreamreal>
well, IDEA is giving me a warning saying 'string key in hash'
<dreamreal>
which makes me think "... is that wrong?"
kinduff has quit [Read error: Connection reset by peer]
<dreamreal>
wait a second... the hashes all look like the keys are lower-cased.
<szqdsegrhrdgdrg>
In Rails in the the ./config/routes.rb, Is it safe to do : `get '' => 'pages#home'` instead of : `root 'pages#home'` ?
akem has quit [Quit: Leaving]
<dreamreal>
gah, okay, the integration endpoint is doing this
alfiemax has quit [Ping timeout: 268 seconds]
troulouliou_div2 has joined #ruby
sergioro has quit [Quit: leaving]
kristian_on_linu has joined #ruby
entel has joined #ruby
szqdsegrhrdgdrg has quit [Remote host closed the connection]
cnsvc has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
cnsvc has quit [Ping timeout: 240 seconds]
bvdw has joined #ruby
markopasha has joined #ruby
szqdsegrhrdgdrg has joined #ruby
<szqdsegrhrdgdrg>
hi
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
hutch has quit [Ping timeout: 265 seconds]
markopasha has quit [Remote host closed the connection]
markopasha has joined #ruby
cnsvc has joined #ruby
hutch has joined #ruby
szqdsegrhrdgdrg has quit [Remote host closed the connection]
cnsvc has quit [Ping timeout: 240 seconds]
Esa_ has quit []
cnsvc has joined #ruby
szqdsegrhrdgdrg has joined #ruby
<szqdsegrhrdgdrg>
hi
<szqdsegrhrdgdrg>
Is it safe to do : `get '' => 'pages#home'` instead of : `root 'pages#home'` ?
hutch has quit [Ping timeout: 260 seconds]
roadie has joined #ruby
wildtrees has joined #ruby
jordanm has joined #ruby
ur5us has joined #ruby
<dreamreal>
okay, I have ... yet another question, maybe about ruby philosophy. I have a gem that's basically an API to call a REST API. It accepts hashes as a data model; it's designed to be used by ANOTHER module that has a generic data model itself. The idea is that the intermediary will convert the ORIGINAL model into an appropriate model for the API, right? ... but what I'm wondering is how much I should
<dreamreal>
worry, from a Rubyist's perspective, about validating that the model has the right data; should I scan for ONLY the right data, or just assume, or...
<szqdsegrhrdgdrg>
dreamreal I still have the same question
<szqdsegrhrdgdrg>
Is it safe to do : `get '' => 'pages#home'` instead of : `root 'pages#home'` ?
<dreamreal>
*nod* I'm coming from languages that are strongly typed so I worry.
<dreamreal>
szqdsegrhrdgdrg: As to your question, I have no idea
davor has quit [Ping timeout: 256 seconds]
kristian_on_linu has quit [Remote host closed the connection]
davor has joined #ruby
<szqdsegrhrdgdrg>
davor hi
gix has joined #ruby
<phaul>
szqdsegrhrdgdrg: root would map the controller action to the root url of the app, whereas get just maps it to pages/home path. so they achieve different things. Therefore Im not sure in this context what safe means
<phaul>
dreamreal: It's specific to the codebase, but I would expect an api distributed as a gem to validate its inputs
<phaul>
dreamreal: and the emphasis is on distributed as a gem. If it's an internal api then it depends
<dreamreal>
well, it's not really a GENERAL-PURPOSE gem (it's for a vertical industry) but... yeah, I'm kinda leaning to wards trying to validate the types fairly strictly ("must have these keys, may have these keys, other keys are rejected")
weird_error has joined #ruby
<phaul>
szqdsegrhrdgdrg: I didn't process your ` quotes properly... ignore my previous answer
hiroaki has quit [Ping timeout: 256 seconds]
mre- has quit [Ping timeout: 256 seconds]
<dreamreal>
... any suggestions on how to implement that with Ruby? :)
<szqdsegrhrdgdrg>
phaul Hi. Thanks for your answer
<szqdsegrhrdgdrg>
but since, '/' is also the root, it will achieve the same behavior
<szqdsegrhrdgdrg>
correct me, if I'm wrong
<phaul>
yeah, I prly agree with you
<szqdsegrhrdgdrg>
I also quickly try it, and they work same
<szqdsegrhrdgdrg>
But i'm sure there is a slighly difference
<wimpog>
hello, I'm selecting DISTINCT records with just one column that I need to then create an array of. However, I need my key to be the same as value.
hutch has joined #ruby
SeepingN has joined #ruby
sergioro has joined #ruby
evdubs has quit [Ping timeout: 256 seconds]
RougeR has joined #ruby
RougeRR has quit [Ping timeout: 240 seconds]
wimpog has quit [Quit: wimpog]
davispuh has joined #ruby
Swyper has quit [Remote host closed the connection]
mre- has joined #ruby
AndroidKitKat has joined #ruby
roadie has quit [Remote host closed the connection]
roadie has joined #ruby
wildtrees has quit [Remote host closed the connection]
royal_screwup21 has joined #ruby
wildtrees has joined #ruby
evdubs has joined #ruby
roadie has quit [Ping timeout: 265 seconds]
pupsikov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ellcs has quit [Ping timeout: 258 seconds]
davispuh has quit [Ping timeout: 255 seconds]
taserface has joined #ruby
davispuh has joined #ruby
davispuh has quit [Client Quit]
Milos has quit [Read error: Connection reset by peer]
davispuh has joined #ruby
Milos has joined #ruby
markopasha has quit [Remote host closed the connection]
wildtrees has quit [Remote host closed the connection]
ianbrown78 has joined #ruby
AndroidKitKat has quit [Remote host closed the connection]
wildtrees has joined #ruby
roadie has joined #ruby
drincruz has quit [Ping timeout: 260 seconds]
ianbrown78 has quit [Ping timeout: 255 seconds]
AndroidKitKat has joined #ruby
ianbrown78 has joined #ruby
AndroidKitKat has quit [Quit: バイバイ〜!]
roadie has quit [Ping timeout: 256 seconds]
AndroidKitKat has joined #ruby
d3bug has joined #ruby
royal_screwup21 has quit [Remote host closed the connection]
leitz has quit [Quit: Leaving]
<apotheon>
havenwood: What are exciting new tools you use with Ruby dev these days?
royal_screwup21 has joined #ruby
entel has quit [Quit: Connection closed for inactivity]
ianbrown78 has quit [Ping timeout: 258 seconds]
ianbrown78 has joined #ruby
mre- has quit [Ping timeout: 256 seconds]
weird_error has quit [Quit: weird_error]
szqdsegrhrdgdrg has quit [Ping timeout: 240 seconds]