title: How can I set a hook to run code at the end of a Ruby class definition?
body: <p>I'm building a plugin that will allow a developer to add various features to a class with a simple declaration in the class definition (following the normal acts_as pattern).</p>
  
  <p>For example, code consuming the plugin might look like</p>
  
  <pre><code>class YourClass
    consumes_my_plugin option1: :value1, specific_method_to_use: :your_method
  end
  </code></pre>
  
  <p>My question arises because I want to error check that the value provided for the :specific_method_to_use parameter exists as a method, but the way code is typically organized and loaded, the method doesn't exist yet.</p>
  
  <p>The code in my plugin tentatively looks like this:</p>
  
  <pre><code>module MyPlugin
    extend ActiveSupport::Concern
  
    module ClassMethods
      def consumes_my_plugin(options = {})
        raise ArgumentError.new("#{options[:specific_method_to_use]} is not defined") if options[:specific_method_to_use].present? &amp;&amp; !self.respond_to?(options[:specific_method_to_use])
      end
    end
  end
  </code></pre>
  
  <p>This would work:</p>
  
  <pre><code>class YourClass
    def your_method; true; end
  
    consumes_my_plugin option1: :value1, specific_method_to_use: :your_method
  end
  </code></pre>
  
  <p>But this is how most people write code, and it would not:</p>
  
  <pre><code>class YourClass
    consumes_my_plugin option1: :value1, specific_method_to_use: :your_method
  
    def your_method; true; end
  end
  </code></pre>
  
  <p>How can I fail at YourClass load time? I want it to error then, not at run time with a NoMethodError. Can I defer execution of the line that raises the ArgumentError until the entire class is loaded, or do something else clever to achieve that?</p>