るりまサーチ

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

別のキーワード

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

ライブラリ

検索結果

SingleForwardable (50030.0)

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

...require '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 メソッ...