title: Usage of as_json and dynamic method
body: <p>I have an simple class (without Rails)</p>
  
  <pre><code>class Tax
  
    attr_reader :guest_age
  
    def initialize(guest_age)
      @guest_age = guest_age
    end
  
    def amount
      0
    end
  
  end
  </code></pre>
  
  <p>This object has an "amount" custom method
  and I want to include the amount result in the json when I do this : <code>tax.as_json(methods: :amount)</code></p>
  
  <p>But this is not working, this return only the object with variables.</p>
  
  <p>What I'm getting now : </p>
  
  <blockquote>
    <p>{ "guest_age": 18 }</p>
  </blockquote>
  
  <p>What I am expecting is :</p>
  
  <blockquote>
    <p>{ "guest_age": 18, "amount": 0 }</p>
  </blockquote>
  
  <p>See <a href="https://apidock.com/rails/ActiveModel/Serializers/JSON/as_json" rel="nofollow noreferrer">https://apidock.com/rails/ActiveModel/Serializers/JSON/as_json</a></p>
  
  <p><strong>Note :</strong></p>
  
  <p>I want to keep this object without active record library dependency.</p>