ruby

Ruby Custom Class Macros with Class Instance Variables

Class macros are class methods that are only used when a class is defined. They allow us to dry up shared code at across classes. In this post, we'll build a custom class macro that leverages class instance variables to define class-specific attributes. Shared Code at the Class Level We'll…

Roll Your Own XML Templater in Ruby

In this post, we'll use Jim Weirich's XML Builder gem and the magic of Tilt to build our very own XML template engine. What is a Template Engine? A template engine is any code or software responsible for creating documents out of a given data model and template. You're probably…

DIY Google reCAPTCHA with Ruby

reCAPTCHA is an anti-bot tool you can implement in your web app to prevent bad actors from programmatically filling out forms and spamming your endpoints. In this post, we'll implement Google's reCAPTCHA protocol using the Google reCAPTCHA 2 client-side library and our very own hand-rolled verification client. I am Not…