refineを使えば特定のクラス内のみに、クラス拡張の影響を限定することができます。

module ExtendArray
  refine Array do
    def hello
      "extend array hello"
    end
  end
end

class ArrayB
  using ExtendArray
  VAL = [3, 4]
  def self.instance_hello
    VAL.hello
  end

  def self.get_array
    [5, 6]
  end
end

ArrayBの中でusingを使っているので、ArrayBの定義内でならExtendArrayモジュールで拡張したメソッドが使うことが出来ます。外部からArrayB.get_arrayで配列を取得した後に拡張メソッドを使おうとしても、NoMethodErrorとなります。

特定の生成したオブジェクトのみに拡張を絞りたい場合はextendメソッドを使います。これでget_hashの戻り値のみに拡張を留めることができます。

module ExtendHello
  def hello
    "ExtendHello hello"
  end
end

module ExtendSay
  def say
    "ExtendSay say"
  end
end

class MyHash
  def self.get_hash
    {}.extend(ExtendHello, ExtendSay)
  end
end