I’m trying to develop a Redmine Plugin, I started reading the documentation, and learning a lot of Ruby and a lot of Ruby on Rails. (I’m a PHP/Python/js guy)
Then I started looking through other plugins, and I found this code. I can’t find enough information to fully understand how this line of code works:
Issue.send(:include, RedmineRequireIssueAllowedToChangeAssignee::Patches::IssuePatch)
I understand that inside IssuePatch are some things to override or add to Issue class.
Then I found this, explaining the use of send, and that confuses me, why not use just Issue.include?
The main question would be: where is this method include defined and what does it does?
UPDATE: related question
You can’t just do
includebecause it’s a private method, so you usesendwhich circumvents ruby visibility control. Withsendyou can call any method, even private ones (as in this case).It’s defined as Module#include and, when invoked with a module as a parameter, it appends all instance methods of that module to the receiver (which is, in your case,
Issueclass). It’s a very-very common idiom in Ruby.