henninb has joined #ruby
Rounin has quit [Ping timeout: 268 seconds]
<mayhew> problem solved :) idling nicely now, my CPU is very happy
<adam12> nakilon: I don’t like the ‘Fake’ prefix for User or Items. I’d probably have a Store struct that had `items`, and then just pass in the Array of created Items. I don’t like the use of #map over an Array when they could of just been instances of Item directly.
<adam12> nakilon: For Roda, I’d create custom exception classes and raise them, then handle that in one place with the errors plugin (or whatever the name of it is, I’d have to look it up).
<adam12> Store could have it’s own lookup method for items, so you wouldn’t have to poke into the items Array repeatedly to do a comparison. Store.find_item(id). Seems like a leaky abstraction.
goldfish has quit [Remote host closed the connection]
<adam12> nakilon: I’d probably have something that represented the Cart too, even if it was a dummy object that just contained logic. Cart.add_item; Cart.items, etc.
<nakilon> there is no cart in the task, the item should be subtracted from balance immediately
<adam12> Ah
<adam12> If you wanted to get fancy, you could stick this in pstore too.
<adam12> Assigning a lambda to a variable inside the routing tree every time seems wasteful. I’d assign it to a constant.
<adam12> Even better, it could just be a method on App.
<nakilon> doesn't it run once?
<adam12> No.
<nakilon> that lambda is about json api, that is only a part of App
<adam12> It’s a new object for every request into that part of the routing tree.
<nakilon> ouch
<adam12> tree: if you were called shrub I’d highlight you less :P
<adam12> nakilon: Using the roda JSON plugin could have just plain Hashes as return values too.
<adam12> I don’t see any content-type header’s being set. Not sure if that’s important.
<nakilon> the company uses Roda without JSON plugin
<adam12> nakilon: I don’t think this is bad code. But I write Roda all day, every day, for like 6 years now, so I’ve seen some things :P
<nakilon> declaring a special error class would make sense if there was any scenario of catching it specifically but it's out of task user scenarios
<nakilon> I agree on defining the items.find method
<nakilon> yeah you've provided good points on something that is planned to evolve into something bigger
aeris- has quit [Ping timeout: 252 seconds]
<nakilon> but the task specifically said: "code should be simple, not complicated, no excessive things..."
<nakilon> thanks for your feedback
<adam12> That’s true. I’m not sure what counts as excessive.
<adam12> Was it asked to be done in Roda?
<nakilon> it was asked to be done in anything
<adam12> Do the responses always have to be in json-api format?
<adam12> I notice the error has those fields, but the happy path doesn’t. Just `data` and `included`.
<tree> adam12: I’m coming to terms with my burden :(
<adam12> tree: lol
<nakilon> what else do you mean? it's specfiically told that "you don't do frontend"
<nakilon> ah, you mean that standard
<adam12> nakilon: I just thought it odd that the sad path has `jsonapi: { version: “1.0”}`, but the happy path does not.
<adam12> Yeah.
<nakilon> the eaxmple on json api website doesn't have version on happy path
<adam12> I just did a json-rpc client that requires something similar on _EVERY_ response. So I thought it was odd.
<adam12> No worries.
ur5us has quit [Ping timeout: 240 seconds]
<mayhew> one question about Roda / Ruby: is it possible to call a module function and keep the same context you'd have inside the `routes do |r|` method to keep the main routing block clean of logic?
<adam12> mayhew: Yes, kinda? I use something like this: instance_exec(r, some_proc)
aeris- has joined #ruby
<adam12> mayhew: I was going to give this example but looking at it now, it looks wrong. It works tho and I use something identical in production. Foo = ->(r) { # yay routing tree }; instance_exec(r, &Foo). I feel like it might be making an unnecessary proc but I’d have to look closer.
<adam12> s/identical/similar
<mayhew> ah cool, I'll have to try playing around with that. I was just passing all of the stuff I needed explicitly and it was getting a bit ugly. Needed to pass request, response, view, any captured route params, etc.
<adam12> >> foo = ->{ “ohai” }; instance_exec(foo)
<ruby[bot]> adam12: # => (https://carc.in/#/r/bd5i)
<adam12> >> foo = ->{ 'ohai’ }; instance_exec(foo)
<ruby[bot]> adam12: # => (https://carc.in/#/r/bd5j)
<adam12> LOL. Apparently my IRC client doesnt’ like single or double quotes.
<adam12> Anyways, &foo would be definitely needed.
henninb has quit [Remote host closed the connection]
<nakilon> >> %{ ohai }
<ruby[bot]> nakilon: # => " ohai " (https://carc.in/#/r/bd5m)
<adam12> "foo"
<adam12> Disable-able I guess.
<adam12> bbl.
lfalcao has quit [Ping timeout: 240 seconds]
ur5us has joined #ruby
<mayhew> instance_exec(&DASHBOARD_HANDLER) worked (where that's a Proc.new), kinda wish I could put it in a `module Dashboard; self.handler` function though. Is that doable?
gearnode has quit [Ping timeout: 244 seconds]
gearnode has joined #ruby
<leftylink> >> "#{%}#{%}#{%}%}}}}}}"
<ruby[bot]> leftylink: # => "%" (https://carc.in/#/r/bd5s)
sdfuiojklqaz has quit [Remote host closed the connection]
sdfuiojklqaz has joined #ruby
sdfuiojklqaz has quit [Ping timeout: 240 seconds]
KramerC has quit [Quit: Leaving]
KramerC has joined #ruby
jetchisel has joined #ruby
postmodern has quit [Remote host closed the connection]
postmodern has joined #ruby
gearnode has quit [Ping timeout: 268 seconds]
pwnd_sfw has quit [Quit: Ping timeout (120 seconds)]
pwnd_sfw has joined #ruby
<ecommence> This is so freaking awesome I feel I wanna cry: https://github.com/jeremyevans/ruby-pledge
jetchisel has quit [Ping timeout: 272 seconds]
jetchisel has joined #ruby
jetchisel has quit [Ping timeout: 240 seconds]
jetchisel has joined #ruby
sdfuiojklqaz has joined #ruby
sdfuiojklqaz has quit [Ping timeout: 264 seconds]
lfalcao has joined #ruby
KramerC has quit [Quit: Leaving]
KramerC has joined #ruby
jetchisel has quit [Ping timeout: 264 seconds]
jetchisel has joined #ruby
ur5us has quit [Ping timeout: 240 seconds]
jetchisel has quit [Ping timeout: 244 seconds]
roadie has joined #ruby
jetchisel has joined #ruby
willthechill has quit [Ping timeout: 264 seconds]
lfalcao has quit [Ping timeout: 268 seconds]
jetchisel has quit [Ping timeout: 264 seconds]
gr33n7007h has quit [Ping timeout: 240 seconds]
postmodern has quit [Quit: Leaving]
teclator has joined #ruby
chrysanthematic has joined #ruby
lunarkitty has quit [Quit: Connection closed for inactivity]
chrysanthematic has quit [Quit: chrysanthematic]
gr33n7007h has joined #ruby
gr33n7007h has quit [Client Quit]
Rounin has joined #ruby
gr33n7007h has joined #ruby
TomyWork has joined #ruby
<keyvan> ecommence: nice! Thanks for the link. Let me dab your tears
mrkz_c has quit [Quit: Connection closed for inactivity]
gearnode has joined #ruby
roadie has quit [Ping timeout: 268 seconds]
roadie has joined #ruby
mrkz_c has joined #ruby
ua_ has quit [Ping timeout: 244 seconds]
aeris- has quit [Quit: ZNC - http://znc.sourceforge.net]
aeris- has joined #ruby
ur5us has joined #ruby
aeris- has quit [Remote host closed the connection]
aeris- has joined #ruby
aeris- has quit [Remote host closed the connection]
aeris22 has joined #ruby
aeris22 has quit [Remote host closed the connection]
_aeris_ has joined #ruby
_aeris_ is now known as aeris
ur5us has quit [Ping timeout: 244 seconds]
<mayhew> in Rails, if I execute two separate activerecord operations; how does that work in terms of connection pooling? Does it individually check in and check out a connection for each operation, or is it smart somehow and use the same connection for both operations without putting it back in the pool?
roadie has quit [Ping timeout: 244 seconds]
roadie has joined #ruby
roadie has quit [Ping timeout: 272 seconds]
roadie has joined #ruby
Bish_ has quit [Quit: leaving]
<adam12> mayhew: Maybe you could use `&Dashboard.method(:handler)`. Or if you named the method #call, maybe even just `&Dashboard`. I didn't test either of these tho.
<adam12> mayhew: I'm pretty sure the connection is checked out of the pool in Rack middleware, so it's the same one for the entire request.
<adam12> Actually, that might be the old way.
gr33n7007h has quit [Read error: Connection reset by peer]
gr33n7007h has joined #ruby
<mayhew> adam12: instance_exec(&Dashboard.method(:handler)) does call Dashboard's self.handler, but it can't access request/response like the Proc could
gearnode has quit [Ping timeout: 244 seconds]
gearnode has joined #ruby
sdfuiojklqaz has joined #ruby
sdfuiojklqaz has quit [Ping timeout: 268 seconds]
sdfuiojklqaz has joined #ruby
billyruffian has joined #ruby
<adam12> mayhew: It probably needs to be bound somehow. maybe add .bind(self) to the end.
billyruffian has quit [Remote host closed the connection]
TomyWork is now known as TomyLobo
TomyLobo has quit [Remote host closed the connection]
Garb0 has joined #ruby
Garb0 has quit [Quit: Garb0]
lfalcao has joined #ruby
lfalcao has quit [Ping timeout: 240 seconds]
motherr has quit [Ping timeout: 268 seconds]
lfalcao has joined #ruby
motherr has joined #ruby
chonkbit has joined #ruby
teclator has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
jinie has quit [Quit: ZNC 1.8.2 - https://znc.in]
jinie has joined #ruby
budo has quit [Ping timeout: 268 seconds]
budo has joined #ruby
jinie has quit [Ping timeout: 244 seconds]
goldfish has joined #ruby
motherr has quit [Quit: motherr]
Winterschlaf has joined #ruby
jetchisel has joined #ruby
gr33n7007h has quit [Ping timeout: 252 seconds]
Winterschlaf has quit [Ping timeout: 252 seconds]
willthechill has joined #ruby
roadie has quit [Quit: ERC (IRC client for Emacs 25.3.50.1)]
jinie has joined #ruby
chrysanthematic has joined #ruby
lfalcao has quit [Ping timeout: 252 seconds]
RougeR has joined #ruby
lfalcao has joined #ruby
ur5us has joined #ruby
chrysanthematic has quit [Quit: chrysanthematic]
lfalcao has quit [Ping timeout: 240 seconds]
chrysanthematic has joined #ruby
ur5us has quit [Ping timeout: 240 seconds]
Garb0 has joined #ruby
Winterschlaf has joined #ruby
chrysanthematic has quit [Changing host]
chrysanthematic has joined #ruby
chrysanthematic has quit [Quit: chrysanthematic]
chrysanthematic has joined #ruby
ur5us has joined #ruby
ur5us has quit [Read error: Connection reset by peer]
Winterschlaf has quit [Ping timeout: 264 seconds]
Winterschlaf has joined #ruby
Winterschlaf has left #ruby [#ruby]
Qchmqs has joined #ruby
jinie has quit [Ping timeout: 252 seconds]
jinie has joined #ruby
chonkbit has quit [Ping timeout: 264 seconds]
jinie has quit [Quit: ZNC 1.8.2 - https://znc.in]
elf_fortrez has joined #ruby
jinie has joined #ruby
Garb0 has quit [Quit: Garb0]
lunarkitty has joined #ruby
Qchmqs has quit [Remote host closed the connection]
pwnd_sfw9 has joined #ruby
pwnd_sfw has quit [Ping timeout: 240 seconds]
pwnd_sfw9 is now known as pwnd_sfw
chrysanthematic has quit [Ping timeout: 264 seconds]
chrysanthematic has joined #ruby
elf_fortrez has quit [Quit: Client closed]
elf_fortrez has joined #ruby
involans has quit [Ping timeout: 264 seconds]
gearnode has quit [Ping timeout: 268 seconds]
jinie has quit [Quit: ZNC 1.8.2 - https://znc.in]
jinie has joined #ruby
jinie has quit [Client Quit]
jinie has joined #ruby
chrysanthematic has quit [Quit: chrysanthematic]
chrysanthematic has joined #ruby
steinomead has joined #ruby
chrysanthematic has quit [Ping timeout: 268 seconds]
gearnode has joined #ruby
chrysanthematic has joined #ruby
chrysanthematic has quit [Ping timeout: 272 seconds]
aeris has quit [Ping timeout: 252 seconds]