title: Overriding setter method for attr_accessor when including InstanceMethods module
body: <p>I have an <code>ActiveRecord</code> extension (abbreviated):</p>
  
  <pre><code>module HasPublishDates
    def self.included(base)
      base.send :extend, ClassMethods
    end
  
    module ClassMethods
      def has_publish_dates(*args)
        attr_accessor :never_expire
  
        include InstanceMethods
      end
    end
  
    module InstanceMethods
      def never_expire=(value)
        @never_expire = ActiveRecord::ConnectionAdapters::Column.value_to_boolean(value)
      end
  
      def another_instance_method
        'something to return'
      end
    end
  end
  
  ActiveSupport.on_load(:active_record) do
    include HasPublishDates
  end
  </code></pre>
  
  <p>which can be called like this:</p>
  
  <pre><code>class MyModel &lt; ActiveRecord::Base
    has_publish_dates
    ...
  end
  </code></pre>
  
  <p>The idea is that <code>never_expire=</code> should override the setter defined by <code>attr_accessor :never_expire</code>. However, it doesn't seem to be working:</p>
  
  <pre><code>m = MyModel.new
  m.never_expire            #=&gt; nil
  m.never_expire = '1'      #=&gt; '1'
  m.never_expire            #=&gt; '1' should be true if never_expire= has been overridden
  m.another_instance_method #=&gt; 'something to return' works as expected
  </code></pre>
  
  <p>As you can see, <code>another_instance_method</code> is being included and is working as expected but <code>never_expire=</code> is not overriding the setter as I expected.</p>
  
  <p>If I change HasPublishDates to use <code>class_eval</code> then it works as expected:</p>
  
  <pre><code>module HasPublishDates
    ...
    module ClassMethods
      def has_publish_dates(*args)
        ...
        class_eval do
          def never_expire=(value)
            @never_expire = ActiveRecord::ConnectionAdapters::Column.value_to_boolean(value)
          end
  
          def another_instance_method
            'something to return'
          end
        end
      end
    end
  end
  ...
  
  m = MyModel.new
  m.never_expire            #=&gt; nil
  m.never_expire = '1'      #=&gt; true
  m.never_expire            #=&gt; true
  m.another_instance_method #=&gt; 'something to return'
  </code></pre>
  
  <p>I imagine that this is because <code>InstanceMethods</code> is defined before <code>attr_accessor :never_expire</code> is called by <code>has_publish_dates</code>.</p>
  
  <p>Though I think that <code>class_eval</code> is an elegant way of doing things I also like the idea of having my instance methods exposed for documentation so there's no "magic" when another developer is trying to use my code.</p>
  
  <p>Is there anyway I can use the <code>include InstanceMethods</code> approach in this scenario?</p>