Skip to content
loading...

re: Custom Ruby Class Macros with Class Instance Variables VIEW POST

FULL DISCUSSION
 

This is an amazing post, thank you! I love learning about how Ruby works in more detail. I had to read it a couple times to really wrap my head around what was going on, but now I'm super excited to know about this pattern.

Once I figured out that the key piece of magic happens here:

  def self.included(base)
    base.extend ClassMethods
  end

and what all of that does, everything clicked into place.

For anyone who needs a refresher on the differences between include and extend, I found this post by Léonard Hetsch to be helpful as well.

code of conduct - report abuse