Ruby metaprogramming

If you are interested in exploiting the true power of Ruby, then the articles on this page are for you.

In the first two part tutorial, I explain the fundamentals in Ruby that allow you to start creating the Domain Specific magic that Rails uses in abundance, such as:

class Book < ActiveRecordBase
  set_table_name :no_standard_name
  has_many :readers

In other words to control you class definitions with special Domain Specific directives.

The two articles explain a few key concepts about objects and classes, before exploring the ‘metaclass’ and finally onto some Rails style code.

  • Part 1 demonstrates how everything in Ruby is an object and that classes definitions are executable code.
  • Part 2 goes on to explore Ruby metaclasses and introduces the syntax to create Rails style DSL code.

1 Comment Add your own

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed

%d bloggers like this: