るりまサーチ

最速Rubyリファレンスマニュアル検索!
12件ヒット [1-12件を表示] (0.026秒)
トップページ > クエリ:class[x] > クエリ:SingleForwardable[x]

別のキーワード

  1. argf.class each
  2. argf.class each_line
  3. argf.class lines
  4. class new
  5. argf.class readline

ライブラリ

検索結果

SingleForwardable (38030.0)

オブジェクトに対し、メソッドの委譲機能を定義するモジュールです。

...quire 'forwardable'
g = Goo.new
g.extend SingleForwardable
g.def_delegator("@out", :puts)
g.puts ...

また、SingleForwardable はクラスやモジュールに対して以下のようにする事もできます。

require 'forwardable'
class
Implementation
def self.service...
...puts "serviced!"
end
end

module Facade
extend SingleForwardable
def_delegator :Implementation, :service
end

Facade.service # => serviced!

もし Forwardable と SingleForwardable の両方を使いたい場合、
def_instance_delegator と def_single_delegator メソッド...