title: Rails: Passing Variables from a Class Method to an Instance Method
body: <p>I have several models that share a concern. Each model passes in a hash, which is meant to handle minor differences in the way they use the concern. I pass the hash in through a class method like so:</p>
  
  <pre><code>add_update_to :group, :user
  </code></pre>
  
  <p>The full code for the concern is:</p>
  
  <pre><code>module Updateable
    extend ActiveSupport::Concern
  
    attr_accessor :streams
  
    module ClassMethods
      def add_updates_to(*streams)
        @streams = streams
      end
    end
  
    module InstanceMethods
      def update_streams
        @streams.collect{|stream| self.public_send(stream)}
      end
    end
  
    included do
      has_one :update, :as =&gt; :updatable
  
      after_create :create_update_and_history
    end
  
    private
      def create_update_and_history
        update = self.create_update(:user_id =&gt; User.current.id)
        self.update_streams.each do |stream|
          stream.histories.create(:update_id =&gt; update.id)
        end
      end
  end
  </code></pre>
  
  <p>Most of this code works, but I'm having trouble passing the hash from the class to an instance. At the moment, I'm trying to achieve this effect by creating a virtual attribute, passing the hash to the attribute, and then retrieving it in the instance. Not only does this feel hacky, it doesn't work. I'm assuming it doesn't work because <code>@streams</code> is an instance variable, so the class method <code>add_update_to</code> can't actually set it?</p>
  
  <p>Whatever the case, is there a better way to approach this problem?</p>