Jan Dudulski

78 Followers
158 Following
237 Posts
NopeJS programmer at http://northpass.com, unfulfilled football player, board/war gamer, Vim cleric and Elixir fanboy.
sitehttps://dudulski.pl
githubhttps://github.com/jandudulski/
blueskyhttps://bsky.app/profile/jan.dudulski.pl
goodreadshttps://www.goodreads.com/user/show/3111218-jan
My #ruby #decider seems to finally shape up the DSL
Decider pattern loves #ruby pattern matching

Let's say that I want to register handlers for different commands. A registered command might be a class that should work for any instances of that class or a primitive and should work called by value.

So I cannot simply do `command.fetch(command.class).call(...)`

Anything better than this comes to your mind, folks?

#ruby

Common table expression, so I can easily query on dynamic columns + #rails `select` and `from` that allows to prepare any query and load data into AR object. I'm not sure if that fits into the “read model” definition, but I found such a “pattern” useful to hide query details for specific views.
One of the weirdest #rspec antipatterns I often see uses anonymous `subject` as variable with value used in assertions. How did we get here? In extreme cases, people just call `subject` to set up dependencies (like insert records to the db) like this:
Parameter Substitution

Current status #zettelkasten
TIL: there are numbered arguments in #ruby since 2.7 😵

I read https://blog.arkency.com/2015/09/testing-race-conditions/ and was wondering if there is any cleaner way for `wait_for_it` flag and here it comes:

TIL: how to wait with threads execution in #ruby so you can start them at the same time as close as possible? welcome `Thread.stop` and `Thread#run`.

By the way, thank you for the blog post Robert! (not on mastodon yet)

Testing race conditions in your Rails app

Testing race conditions in your Rails app From time to time, there comes a requirement in your application where you have to guarantee that something can be done at most X number of times. For example, only 15 people can subscribe to a course, only limited number of people can buy this physical or virtual product, only 200 people can go to a concert, etc. How do you test that this limitation actually work? And not only work but that it works under heavy load, when there are multiple customers trying to buy the last item because it is a hot event or the product is offered with a big discount?

Arkency Blog