Rails - Self joins
===

I currently have a <code>metric</code> model, that can take two <code>operands</code> and perform a calculation based on its <code>operation_type</code>, producing a result through the custom result method. This is working as expected.

In order to make this scalable, I would like to be able to use two operands (as currently), one operand and one metric, or two metrics to perform the calculation. The reason for this is that it is then scalable - I can use the results of previous operations.

Where I am stuck is how to create this self join - I imagine that I need to go down the road of a polymorphic self reference somehow, but the documentation is not leading me to the answer. I have currently got a setup with a <code>calculated_metric</code> model in addition, but i'm not sure if this is the way to go.

My models look as follows:

    class Metric < ActiveRecord::Base
        attr_accessible :name, :operation_type_id
    end

    class Operand < ActiveRecord::Base
        attr_accessible :object, :attribute
    end

    class Calculated_metric < ActiveRecord::Base
        attr_accessible :metric_id, :calculated_metric_id
    end

Any assistance would be greatly appreciated. Thanks!