The Ruby Craftsman

Posts

ActiveRecord Scopes can be nice to use and a useful way to think about data.
Chaining methods together in logical filters to get the desired results without having to think about the structure of the data.
ActiveRecord is tided to doing database queries, but to do that you must have a database. Have you ever wanted use this kind of syntax on a set of custom in-memory objects or an array of hashes?
Now let’s not let ActiveRecord have all the fun we can do the same thing in plain old Ruby and I’ll show you how.

Learn how to refactor from a mutable object into an immutable one while still being able to make changes to state.
I’ll start with an Account class and show how you would let it emit new objects instead of changing the previous one.
I walk step by step through the refactor process and talk about its possible advantages.