Ruby 2.7.0 リファレンスマニュアル > ライブラリ一覧 > delegateライブラリ > Delegatorクラス

class Delegator

クラス・モジュールの継承リスト: Delegator < Object < Kernel < BasicObject

要約

サブクラスにメソッド委譲の仕組みを提供する抽象クラス。

メソッド委譲を行う場合は、本クラスを継承しDelegator#__getobj__を再定義する必要があります。

具体的な使用例については、SimpleDelegatorを参照してください。

インスタンスメソッド

定義 説明
! self -> bool

自身を否定します。

self != obj -> bool

自身が与えられたオブジェクトと等しくない場合は、真を返します。そうでない場合は、偽を返します。

self == obj -> bool

自身が与えられたオブジェクトと等しい場合は、真を返します。そうでない場合は、偽を返します。

__getobj__ -> object

委譲先のオブジェクトを返します。

__setobj__(obj) -> object

委譲先のオブジェクトをセットします。

freeze -> self

自身を凍結します。

marshal_dump -> object

シリアライゼーションをサポートするためにDelegator#__getobj__ が返すオブジェクトを返します。

marshal_load(obj) -> object

シリアライズされたオブジェクトから、Delegator#__getobj__ が返すオブジェクトを再現します。

method_missing(m, *args) -> object

渡されたメソッド名と引数を使って、Delegator#__getobj__ が返すオブジェクトへメソッド委譲を行います。

methods -> [Symbol]

そのオブジェクトに対して呼び出せるメソッド名の一覧を返します。このメソッドは public メソッドおよび protected メソッドの名前を返します。

protected_methods(all = true) -> [Symbol]

そのオブジェクトが理解できる protected メソッド名の一覧を返します。

public_methods(all = true) -> [Symbol]

そのオブジェクトが理解できる public メソッド名の一覧を返します。

respond_to?(m) -> bool

Delegator#__getobj__ が返すオブジェクトが メソッド m を持つとき真を返します。

respond_to_missing?(m, include_private) -> bool

@param m メソッド名を指定します。

継承したメソッド

__id__ __send__ instance_eval instance_exec singleton_method_added singleton_method_removed singleton_method_undefined !~ <=> === =~ _dump class clone define_singleton_method display enum_for eql? equal? extend frozen? hash initialize initialize_copy inspect instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? itself method nil? object_id pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods psych_to_yaml public_method public_send remove_instance_variable send singleton_class singleton_method singleton_methods taint tainted? tap then to_a to_ary to_hash to_int to_io to_proc to_regexp to_s to_str trust untaint untrust untrusted? .new .yaml_tag ::ARGF ::ARGV ::DATA ::ENV ::FALSE ::NIL ::RUBY_COPYRIGHT ::RUBY_DESCRIPTION ::RUBY_ENGINE ::RUBY_ENGINE_VERSION ::RUBY_PATCHLEVEL ::RUBY_PLATFORM ::RUBY_RELEASE_DATE ::RUBY_REVISION ::RUBY_VERSION ::SCRIPT_LINES__ ::STDERR ::STDIN ::STDOUT ::TOPLEVEL_BINDING ::TRUE