title: Rails 4 Monkey patch throws exception when executing class method
body: <p>I have a rails project which uses <a href="https://github.com/NoamB/sorcery" rel="nofollow">Sorcery</a> for authentication.  I want to modify the behavior of the password reset function such that it does not create a new reset token if one already exists.  I believe the relevant code is:</p>
  
  <pre><code>  def deliver_reset_password_instructions!
      config = sorcery_config
      # hammering protection
      return false if config.reset_password_time_between_emails.present? &amp;&amp; self.send(config.reset_password_email_sent_at_attribute_name) &amp;&amp; self.send(config.reset_password_email_sent_at_attribute_name) &gt; config.reset_password_time_between_emails.seconds.ago.utc
      self.class.sorcery_adapter.transaction do
        generate_reset_password_token!
        send_reset_password_email! unless config.reset_password_mailer_disabled
      end
    end
  </code></pre>
  
  <p>I created the following monkey patch to rectify the problem:</p>
  
  <pre><code>Sorcery::Model::Submodules::ResetPassword::InstanceMethods.module_eval do
    def deliver_reset_password_instructions!
      config = sorcery_config
      # hammering protection
      return false if config.reset_password_time_between_emails.present? &amp;&amp; self.send(config.reset_password_email_sent_at_attribute_name) &amp;&amp; self.send(config.reset_password_email_sent_at_attribute_name) &gt; config.reset_password_time_between_emails.seconds.ago.utc
      self.class.sorcery_adapter.transaction do
        generate_reset_password_token! unless reset_password_token.present?
        send_reset_password_email! unless config.reset_password_mailer_disabled
      end
    end
  end
  </code></pre>
  
  <p>I get the following error in development:</p>
  
  <p><code>undefined method `sorcery_adapter' for #&lt;Class:0x00000008b82d08&gt;</code></p>
  
  <p>I would greatly appreciate any insights or suggestions concerning why this is happening, how to create a functional patch, or a better way of going about the whole thing.  Thanks in advance.</p>