182件ヒット
[1-100件を表示]
(0.084秒)
別のキーワード
種類
- インスタンスメソッド (132)
- 文書 (28)
- モジュール (11)
- ライブラリ (11)
ライブラリ
- forwardable (143)
モジュール
- Forwardable (66)
- SingleForwardable (66)
キーワード
-
NEWS for Ruby 2
. 6 . 0 (6) - Ruby用語集 (11)
- SingleForwardable (11)
-
def
_ delegator (22) -
def
_ delegators (22) -
def
_ instance _ delegator (11) -
def
_ instance _ delegators (11) -
def
_ single _ delegator (11) -
def
_ single _ delegators (11) - delegate (22)
-
instance
_ delegate (11) -
ruby 1
. 6 feature (11) -
single
_ delegate (11)
検索結果
先頭5件
-
forwardable (38016.0)
-
クラスやオブジェクトに、メソッドの委譲機能を追加するためのライブラリです。
...クラスやオブジェクトに、メソッドの委譲機能を追加するためのライブラリです。
=== 参考
* Rubyist Magazine 0012 号 標準添付ライブラリ紹介【第 6 回】委譲 (https://magazine.rubyist.net/articles/0012/0012-BundledLibraries.html)... -
Forwardable
# def _ delegator(accessor , method , ali = method) -> () (17036.0) -
メソッドの委譲先を設定します。
...を設定します。
@param accessor 委譲先のオブジェクト
@param method 委譲先のメソッド
@param ali 委譲元のメソッド
委譲元のオブジェクトで ali が呼び出された場合に、
委譲先のオブジェクトの method へ処理が委譲されるようにな......require 'forwardable'
class MyQueue
extend Forwardable
attr_reader :queue
def initialize
@queue = []
end
def_delegator :@queue, :push, :mypush
end
q = MyQueue.new
q.mypush 42
q.queue # => [42]
q.push 23 # => NoMethodError
@see Forwardable#def_delegato... -
Forwardable
# def _ instance _ delegator(accessor , method , ali = method) -> () (17036.0) -
メソッドの委譲先を設定します。
...を設定します。
@param accessor 委譲先のオブジェクト
@param method 委譲先のメソッド
@param ali 委譲元のメソッド
委譲元のオブジェクトで ali が呼び出された場合に、
委譲先のオブジェクトの method へ処理が委譲されるようにな......require 'forwardable'
class MyQueue
extend Forwardable
attr_reader :queue
def initialize
@queue = []
end
def_delegator :@queue, :push, :mypush
end
q = MyQueue.new
q.mypush 42
q.queue # => [42]
q.push 23 # => NoMethodError
@see Forwardable#def_delegato... -
Forwardable
# def _ delegators(accessor , *methods) -> () (17024.0) -
メソッドの委譲先をまとめて設定します。
...定します。
@param accessor 委譲先のオブジェクト
@param methods 委譲するメソッドのリスト
委譲元のオブジェクトで methods のそれぞれのメソッドが呼び出された場合に、
委譲先のオブジェクトの同名のメソッドへ処理が委譲さ......_delegators は def_instance_delegators の別名になります。
また、以下の 2 つの例は同じ意味です。
def_delegators :@records, :size, :<<, :map
def_delegator :@records, :size
def_delegator :@records, :<<
def_delegator :@records, :map
@see Forwardable#def_delegator... -
Forwardable
# def _ instance _ delegators(accessor , *methods) -> () (17024.0) -
メソッドの委譲先をまとめて設定します。
...定します。
@param accessor 委譲先のオブジェクト
@param methods 委譲するメソッドのリスト
委譲元のオブジェクトで methods のそれぞれのメソッドが呼び出された場合に、
委譲先のオブジェクトの同名のメソッドへ処理が委譲さ......_delegators は def_instance_delegators の別名になります。
また、以下の 2 つの例は同じ意味です。
def_delegators :@records, :size, :<<, :map
def_delegator :@records, :size
def_delegator :@records, :<<
def_delegator :@records, :map
@see Forwardable#def_delegator... -
Forwardable
# delegate(hash) -> () (17018.0) -
メソッドの委譲先を設定します。
...譲先のメソッドがキー、委譲先のオブジェクトが値の
Hash を指定します。キーは Symbol、
String かその配列で指定します。
例:
require 'forwardable'
class Zap
extend Forwardable
delegate :length => :@str
delegate... -
Forwardable
# instance _ delegate(hash) -> () (17018.0) -
メソッドの委譲先を設定します。
...譲先のメソッドがキー、委譲先のオブジェクトが値の
Hash を指定します。キーは Symbol、
String かその配列で指定します。
例:
require 'forwardable'
class Zap
extend Forwardable
delegate :length => :@str
delegate... -
SingleForwardable (14040.0)
-
オブジェクトに対し、メソッドの委譲機能を定義するモジュールです。
...オブジェクトに対し、メソッドの委譲機能を定義するモジュールです。
=== 使い方
オブジェクトに対して extend して使います。
例:
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, :s......ervice
end
Facade.service # => serviced!
もし Forwardable と SingleForwardable の両方を使いたい場合、
def_instance_delegator と def_single_delegator メソッドの方を呼び出して
ください。... -
SingleForwardable
# def _ delegator(accessor , method , ali = method) -> () (11018.0) -
メソッドの委譲先を設定します。
...を設定します。
@param accessor 委譲先のオブジェクト
@param method 委譲先のメソッド
@param ali 委譲元のメソッド
委譲元のオブジェクトで ali が呼び出された場合に、
委譲先のオブジェクトの method へ処理が委譲されるようにな......ります。
委譲元と委譲先のメソッド名が同じ場合は, ali を省略することが可能です。
def_delegator は def_singleton_delegator の別名になります。
@see SingleForwardable#def_delegators... -
SingleForwardable
# def _ delegators(accessor , *methods) -> () (11018.0) -
メソッドの委譲先をまとめて設定します。
...定します。
@param accessor 委譲先のオブジェクト
@param methods 委譲するメソッドのリスト
委譲元のオブジェクトで methods のそれぞれのメソッドが呼び出された場合に、
委譲先のオブジェクトの同名のメソッドへ処理が委譲さ......tors は def_singleton_delegators の別名になります。
また、以下の 2 つの例は同じ意味です。
def_delegators :@records, :size, :<<, :map
def_delegator :@records, :size
def_delegator :@records, :<<
def_delegator :@records, :map
@see SingleForwardable#def_delegator...