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…

Roll Your Own XML Templater in Ruby

In this post, we'll use Jim Weirich's XML Builder gem [https://github.com/jimweirich/builder] and the magic of Tilt [https://github.com/rtomayko/tilt] to build our very own XML template engine. What is a Template Engine? A template engine is any code or software…

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…