title: Ruby: How do I include methods from a Module into a subclass of ActiveModel::Serializer
body: <p>I'm trying to include a method from a helper module into an <code>ActiveModel::Serializer</code> subclass but for some reason the method is not showing up.</p>
  
  <p>Here's my simple helper module:</p>
  
  <pre><code>module Helpers
    module Serialisers
      def enforce_zulu_time(attribute)
        define_method(attribute) do
          object.send(attribute).utc.iso8601 unless object.try(attribute).nil?
        end
      end
    end
  end
  </code></pre>
  
  <p>And here's my test serialiser</p>
  
  <pre><code>class TestSerialiser &lt; ActiveModel::Serializer
    include Helpers::Serialisers
    attributes :updated_at
  
    enforce_zulu_time :updated_at
  end
  </code></pre>
  
  <p>and my simple object to serialise</p>
  
  <pre><code>class TestItem
    include ActiveModel::SerializerSupport
    attr_reader :updated_at
    def initialize
      @updated_at = Time.now.utc
    end
  end
  </code></pre>
  
  <p>and my test</p>
  
  <pre><code>describe Helpers::Serialisers do
    let(:item)       { TestItem.new }
    let(:serialiser) { TestSerialiser.new(item) }
    subject          { serialiser.attributes }
  
    it { expect(subject[:updated_at]).to be_zulu_time}
  end
  </code></pre>
  
  <p>results in</p>
  
  <pre><code>`&lt;class:TestSerialiser&gt;': undefined method `enforce_zulu_time' for TestSerialiser:Class (NoMethodError)
  </code></pre>
  
  <p>However if I just do this in my <code>TestSerialiser</code> instead</p>
  
  <pre><code>class TestSerialiser &lt; ActiveModel::Serializer
    attributes :updated_at
  
    ['updated_at'].each do |attribute|
      define_method(attribute) do
        object.send(attribute).utc.iso8601 unless object.send(attribute).blank?
      end
    end
  end
  </code></pre>
  
  <p>it all works fine.</p>
  
  <p>Why is my <code>enforce_zulu_time</code> method not being included?</p>