module DelegateMissingTo

Delegates missing methods to another object(s). May be useful for inheritance mechanisms, decorator pattern or graceful object replacement for refactoring.

Example with delegation of missing methods to an association:

class A < ActiveRecord::Base
  def qwe
    123
  end
end

class B < ActiveRecord::Base
  include ActiveRecord::DelegateMissingTo

  belongs_to :a
  delegate_missing_to :a
end

b = B.new
b.qwe # => 123

Additionally you may specify a delegation chain:

delegate_missing_to :first_priority, :second_priority, :third_priority