before_destroy, validatesetc. are not attributes or anything like that. These are method calls.
In ruby, the class body is all executable code, which means that each line of the class body is executed by the interpreter in the same way as the body of the method.
before_destroy :my_func - ruby. before_destroy, :my_func . ( ), .
, , , ,
module MyModule
before_destroy :my_func
def my_func
...
end
end
before_destroy . , , , , . Module#included:
module MyModule
module InstanceMethods
def my_func
...
end
end
def self.included(base)
base.send :include, InstanceMethods
base.before_destroy :my_func
end
end