The Ruby Craftsman
Posts
-
AWS Lambda + Ruby = Podcast [tutorial]
Learn how to write a Lambda function in Ruby to create a Podcast feed.
-
The Power of Ruby Structs
I invite you to explore beyond ActiveRecord models and into the world of PORO (Plain Old Ruby Objects). These are the building block of any Object Oriented Language and especially Ruby. I’m going to focus on Value Objects, which holders of some collection of data or attributes. The collection could model a person, an account, an address, or more abstractly an error, and many more. You should keep in mind as a general principle that these objects should have a well-defined purpose or identity and contain no more information than what is needed.
-
Visualize Ruby Execution
In my last post, I showed how Ruby code could be transformed into a flowchart using static analysis, which is done with the gem VisualizeRuby. Building upon that I’ve added the ability to show the execution path on the flowchart. It highlights each corresponding node for each line of code executed. For building flowcharts with Ruby code I’ve got a neat demo page, but to add the execution path to this demo would be a security issue, see remote code execution vulnerability. Since there is not an easy way to make that happen safely, you’ll have to follow along at home on your own computer’s.
-
Visualize Ruby with Flowcharts
See Ruby control flow and methods calls as flow charts. Helps developers better understand code and explain it to the non-technical. By using the DSL you already know, Ruby.
-
Custom Ruby Collections with ActiveRecord Like Scopes [Video]
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.
subscribe via RSS