
Welcome lecture. Here you will learn who this course is for and what you will learn.
This lecture gives you an overview of the course layout, its structure and birds eye view agenda. Also, you will find contact details for your feedback or more individual one-on-one help.
This insight shows that everything is an object in ruby. Numbers, booleans, even top level scope is run within an object.
Many other insights, that we will cover, are only possible because of this feature of ruby language. That's why, it is very important that you remember this feature of ruby.
The key to any learning is to make sure that you retain newly acquired information. And the best way to guarantee high retention is to do material revision.
In this revision lecture, you will be reminded about the key points from the 2 previous video lectures and also get some more nuances that I did not cover. I will do this by demonstrating an example code. So, you need to analyse the code and make your own conclusions. This step is also key for deep learning.
In this lecture you will learn that classes in ruby are objects themselves. This is the key insight that you need to understand about the ruby classes. The whole ruby metaprogramming is only possible because of this feature of ruby classes.
You will learn that your class names are just constants, and your classes are just an instances of "Class" class from standard ruby library.
The key to any learning is to make sure that you retain newly acquired information. And the best way to guarantee high retention is to do material revision.
In this revision lecture, you will be reminded about the key points from the "Classes are objects" video and also get some more nuances that I did not cover. I will do this by demonstrating some example code. So, take your time and analyse the code and make your own conclusions about it. This step is key for deep learning.
This insight talks about scopes. You will learn when, how, why and to what scopes are changed in your ruby code.
Also, you will be given a simple rule that explains all possible scope changes. Remember the rule and you will always know the value of current "self".
The key to any learning is to make sure that you retain newly acquired information. And the best way to guarantee high retention is to do material revision.
In this revision lecture, you will be reminded about the key points from the "Scopes" video and also get some more nuances that I did not cover in the video. I will do this by demonstrating some example code. So, take your time and analyse the code and make your own conclusions about it. This step is key for deep learning.
This insight shows that classes and modules in ruby are essentially the same with the only difference being that you can initialise and build inheritance hierarchies with classes, but not modules.
The key to any learning is to make sure that you retain newly acquired information. And the best way to guarantee high retention is to do material revision.
In this revision lecture, you will be reminded about the key points from the "Classes are modules with hierarchy" video and also get some more nuances that I did not cover in the video. I will do this by demonstrating some example code. So, take your time and analyse the code and make your own conclusions about it. This step is key for deep learning.
In this video, you will learn all about inheritance in ruby. How classes' inheritance is built and how included modules fit into the picture (in what order, etc.).
The key to any learning is to make sure that you retain newly acquired information. And the best way to guarantee high retention is to do material revision.
In this revision lecture, you will be reminded about the key points from the "Inheritance hierarchy" video and also get some more nuances that I did not cover in the video. I will do this by demonstrating some example code. So, take your time and analyse the code and make your own conclusions about it. This step is key for deep learning.
Unlike other programming languages, ruby classes don't have class properties. They just spring into existence when they are assigned a value. In this video, you will try to understand and visualise where instance variables and methods reside.
Understanding it will help you better understand why your code can or cannot access an instance variable or a method. Also, it will be of great help to understand ruby method lookup rules.
Quick revision for "Where variables and methods live?" video lecture.
This insight shows and explains which exact method definition ruby will call when you send a message to an object. You will be given a list of 4 simple and easy to remember directives, that ruby uses to find a method.
Knowing which exact method will be executed is the key to doing metaprogramming. You will need to know exactly where you should dynamically add a method to achieve your goal. So, make sure you pay special attention during this lecture.
Quick revision for "Method lookup" video lecture. In this revision, we will apply the insight from previous revision lecture and drastically simplify the method lookup rule.
This insight is all about variables and variable scope changes in ruby language. You will learn all about the following variable scopes:
You will also learn about each variable lifeline. When a variables is created and when is it removed/unset.
In this lecture, you will put everything you've learned so far into a grand picture, that is known as "Ruby Object Model".
I tried to make this lecture more visual with code examples that starts with a simple code and incrementally builds into more complex structure that shows different aspects of ruby object model. Also, everything will be visualized to help you grasp the ideas and concepts more easily.
In this lecture, I will point out some aspects of blocks in Ruby that you need to know to use their full potential in your metaprogramming practice. Along the way, you will demystify one of the common tricks used in Ruby on Rails (&:symbol) and understand how/why it works.
In this video, you will learn about methods from ruby standard library that get information about your objects. For example, object class, name, defined public, private, protected, instance, singleton methods, etc. Also, about available variables, their values and how to change their values.
In this video you will learn one of your first metaprogramming tricks. You will learn how to create/imitate custom language keywords like "require", "raise", "puts" or ActiveRecord's "validates" methods.
In this video, we will continue to go through methods from Standard Ruby Library that are used in metaprogramming. We've already learned about the methods that help us get information about classes, available methods and variables. So, it is about time to learn how to create them.
In this video, you will learn how you can create your own method that behaves just like built-in "attr_accessor" method. Also, you will learn that this technique can be used to create methods from Rails. Such as: "validates", "belongs_to", "attr_accessible", etc. from ActiveRecord classes. This will completely demystify the magic behind these Rails' methods.
You've learned about creating and getting information about classes, methods and all kinds of variables. Now, it time to learn what methods Ruby standard library provides in order to change existing code. You will learn all methods that help you change your classes, methods and variables.
In this video, we will build our own method that behaves just like "alias_method_chain" method from Rails. This will help you demystify the magic behind and help you write your own similar methods for your own projects.
So, you've learned all about methods that let you create, change and remove classes, methods and variables. Learning how to run any code in different scope increases your possibilities by many fold. So, in this video, you will do just that! You will learn about different methods that Ruby has to offer.
It's really handy to be able to intercept and hook into the changes that happen in your classes and modules. You can add some custom behavior or validations when a module is included within another class for example.
This is a really simple concept, but only highly dynamic language such as Ruby could have functionality like this.
If you have developed for Rails, you should have used its' "ActiveSupport::Concern" helper module. In this video, you will build your own "ActiveSupport::Concern" helper module. If you don't want to include the whole "ActiveSupport" gem into your project just for this feature, you will be able to always write your own.
I will go through the "ActiveSupport::Concern" module code from Rails and explain how it is implemented. This demo will give you an idea of how all the methods you've learned in this section work together to achieve some requirement.
`.tap` method was introduced in Ruby 1.9. But, you can create it yourself using the methods that we've covered. This tasks explains the `.tap` method and defines the exercise.
In this video I demonstrate and walk you through the process of writing .tap() method and further improving it.
This task introduces some features of "Struct" class from the Standard Ruby Library and asks you implement them.
In this video, you will see an implementation of `Struct` class. We will build `ConStruct` class together (pun intended) that duplicates features of the `Struct` class from the Standard Ruby Library.
This task requires you to create a custom DSL for generating HTML code. Just like many popular ruby gems (eg. arbre).
In this video, I show a solution to previous task. You will learn how can you write a code that is combined with the Ruby language's syntax imitates a custom DSL.
In this video we will look into the ways how we can run code in isolated scopes or "blank slate" environment.
You will learn how to create shared scopes between different methods or classes that no one else can access.
In this lecture, we will go through many "magical" code in Rails' source code and consider different ways they can be implemented. Also, you will learn the reasons behind why those "tricks" work.
Just like many other ruby developers, I wanted to learn metaprogramming to make the leap from Ruby novice to Ruby pro. But, approaching the subject felt a bit intimidating. I tried to learn metaprogramming several times and every time I tried, all available materials were referring to even more complicated and less known concepts such as: eigenclasses, singleton classes, ruby object model, classes being objects themselves, etc.
So, I spent several months reading about all these concepts and synthesised all available material. At the end, it just "clicked"! It turned out to be very simple! The problem was that there was no single resource where all this concepts were put together. So, I decided to produce this corse. I hope it will save your time and you will find it useful.
This video course will teach you ruby metaprogramming by introducing small, simple and less known ruby insights in each video. And once you learn them, metaprogramming will just start to make sense.
At the end of the course, you will:
Course overview
Metaprogramming is such an integral part of the Ruby language, that in order to learn it, you need to understand the specific language features of Ruby. This features are less known and not covered in books. But, once you are introduced to them, metaprogramming starts to make sense. That's why, the course will start by introducing several key Ruby language insights. After this section, you will understand why is it that some method or variable is not available in some scope and available in others or how scope changes in your code and more.
In the second section of the course, we will cover all the SDK methods that are involved in metaprogramming. Along the way, we will go through several examples that demystifies magic behind most popular gem code as well.
In the last section of the course, we will put everything we've learnt into practice and will build our own rspec, domain specific language and some of the rails most popular magical methods.