Project

General

Profile

Actions

Feature #10355

closed

Feature request: Module#prepended?(mod)

Added by tagomoris (Satoshi Tagomori) over 9 years ago. Updated about 6 years ago.

Status:
Feedback
Target version:
-
[ruby-dev:48610]

Description

あるモジュール X に対してモジュール P1 がprependされているかどうかを調べる方法があると嬉しく思います。
Module#include? を使うと継承関係に含まれているかどうかはわかりますが、それが対象モジュールに対してprependされたものかは分かりません。

module P1; end
module P2; end

class X
  prepend P1
end
class Y< X
  prepend P2
end

X.include?(P1) #=> true
Y.include?(P2) #=> true
Y.include?(P1) #=> true

# I want
X.prepended?(P1) #=> true
Y.prepended?(P2) #=> true
Y.prepended?(P1) #=> false
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0