Class: AgentXmpp::Delegate
Overview
Instance Attribute Summary collapse
-
#methods ⇒ Object
readonly
.….….….….….….….….….….….….….….….….….….….….….….….….….….
Instance Method Summary collapse
-
#add_delegate_methods(methods) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#delegate(pipe, delegate) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#initialize ⇒ Delegate
constructor
.….….….….….….….….….….….….….….….….….….….….….….….….….….
-
#method_missing(meth, *args, &blk) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
Constructor Details
#initialize ⇒ Delegate
.….….….….….….….….….….….….….….….….….….….….….….….….….….
67 68 69 |
# File 'lib/agent_xmpp/client/response.rb', line 67 def initialize @methods = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
93 94 95 |
# File 'lib/agent_xmpp/client/response.rb', line 93 def method_missing(meth, *args, &blk) methods.send(meth, *args, &blk) end |
Instance Attribute Details
#methods ⇒ Object (readonly)
.….….….….….….….….….….….….….….….….….….….….….….….….….….
64 65 66 |
# File 'lib/agent_xmpp/client/response.rb', line 64 def methods @methods end |
Instance Method Details
#add_delegate_methods(methods) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
72 73 74 |
# File 'lib/agent_xmpp/client/response.rb', line 72 def add_delegate_methods(methods) @methods << methods end |
#delegate(pipe, delegate) ⇒ Object
.….….….….….….….….….….….….….….….….….….….….….….….….….….
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/agent_xmpp/client/response.rb', line 77 def delegate(pipe, delegate) methods.each do |meths| meths.each do |(meth,blk)| delegate.(meth) do |*args| if res = blk.call(*args) pipe.send_resp(res) pipe.remove_delegate(delegate) end end end pipe.add_delegate(delegate) end methods.clear end |