Is that to provide blocks instead of methods in the controller?
No, mostly for configuration purposes.
It can be useful in cases when you need something like class_attribute but you need to run a block in getter in instance context.
One can define method, but it would look less like metaprogramming. And also if method should be with specified visibility, it’s moved down to the right section, or one have to explicitly declare protected :method in every class where it’s defined.
The most common example is ActiveController::Base::layout method.
That’s what I’m asking, something like
class UserController < … layout do run_this_in_instance_ctx end
???
yeah, but not only controllers - any class