The Ruby Object Model and Metaprogramming

PragProg · 11K views · 2010 · 9:22

Open on YouTube

Python, Ruby & scripting languagesProgramming language designtutorial

Why Stack Overflow recommends it

Stack Overflow users link it when answering questions about singleton methods, class methods, and how Ruby's object model works under the hood.

Recommended by 2 people across 2 different months, 2014 to 2015.

What it is

A roughly nine-minute episode from the Pragmatic Programmers series in which Dave Thomas explains the Ruby object model and metaprogramming. It covers singletons, self, and metaclasses, and aims to make the underlying model simple enough that metaprogramming behaves predictably.

What people said

Recommends Rubyrider · 2014-11 · Stack Overflow · on “Ruby: Different ways to declare a method on a class”

class User < ActiveRecord::Base def something .... end end Answer: this method will be available to this class's instance/object's singleton class. class User < ActiveRecord::Base def User.something .... end end class User < ActiveRecord::Base def self.something .... end end class User < ActiveRecord::Base class << self def something ....... end end end These last 3 methods are defined to class level. Basically, classes are object so programmatically they will be only available to those class. If you don't mind I would like to suggest you to watch the following video. The Ruby Object Model and Metaprogramming [this video]

Recommends Rubyrider · 2014-11 · Stack Overflow · on “Ruby: Different ways to declare a method on a class”

okey let me remove that. But watch the video link I provided. You will like that and get more constructive ideas about ruby object which more important to understand first. So these question will be clear to you. [this video]

Recommends Gupta · 2015-12 · Stack Overflow · on “Singleton method vs. class method”

Most of what happens in Ruby involves classes and modules, containing definitions of instance methods class C def talk puts "Hi!" end end c = C.new c.talk Output: Hi! But as you saw earlier (even earlier than you saw instance methods inside classes), you can also define singleton methods directly on individual objects: obj = Object.new def obj.talk puts "Hi!" end obj.talk #Output: Hi! When you define a singleton method on a given object, only that object can call that method. As you’ve seen, the most common type of singleton method is the class method—a method added to a Class object on an individual basis: class Car def self.makes %w{ Honda Ford Toyota Chevrolet Volvo } end end But any obje

Cites GuruM · 2014-03 · Stack Overflow · on “Good documentation for writing Redmine plugins”

I know this maybe too-late for the original question poster but might help someone else in a similar situation. Below links are for a total newbie (like me) to RubyOnRails but someone who's programmed before. You can pick and choose the relevant ones as per your skill level. Understanding Redmine (functionality): If you're not familiar with Redmine or administering other Issue Tracking Software Mastering Redmine [LINK] book is an ok place to start. It's not very densely packed so it'll help only as a structured organization of information. If you want more dense information go through the documentation instead. Understanding Redmine Plugins: "Redmine Plugin Extension and Development" by Alex