title: Define instance methods in Concern dynamically on Rails
body: <p>I just want to convert user input params into a Time object, so I trying to define a concern for that.</p>
  
  <pre><code>class Foo &lt; ActiveRecord::Base
    include DateAttribute
    attr_date :date_column_1, :date_column_2
  end
  </code></pre>
  
  <p>But when I write that concern, I got a problem that how to define a instance methods in module's class_methods block.</p>
  
  <pre><code>module DateAttribute
    extend ActiveSupport::Concern
  
    included do
      class_attribute :_attr_date, instance_accessor: false
  
      self._attr_date = []
    end
  
    class_methods do
      def attr_date(*attributes)
        self._attr_date = Set.new(attributes.map(&amp;:to_s))
  
        # how to dynamic define setter methods by loop attributes here
      end
  
      def date_attributes
        self._attr_date
      end
    end
  end
  </code></pre>
  
  <p>Thanks.</p>