Class: JIJI::Permitter::Request
- Inherits:
-
Object
- Object
- JIJI::Permitter::Request
- Defined in:
- lib/jiji/agent/permitter.rb
Overview
メソッド呼び出しリクエスト
Instance Method Summary collapse
-
#exec(permitter) ⇒ Object
リクエストを実行する.
-
#initialize(receiver, name, args, block = nil, allows = [], proxy_result = []) ⇒ Request
constructor
A new instance of Request.
-
#wait ⇒ Object
リクエストの完了を待ち、結果を返す。.
Constructor Details
#initialize(receiver, name, args, block = nil, allows = [], proxy_result = []) ⇒ Request
Returns a new instance of Request.
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/jiji/agent/permitter.rb', line 87 def initialize( receiver, name, args, block=nil, allows=[], proxy_result=[] ) @name = name @args = args @block = block @receiver = receiver @mutex = Mutex.new @cv = ConditionVariable.new @finished = false @value = nil @error = nil @allows = allows @proxy_result = proxy_result end |
Instance Method Details
#exec(permitter) ⇒ Object
リクエストを実行する
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/jiji/agent/permitter.rb', line 109 def exec( permitter ) begin m = @name + "_without_permittion" @value = @block ? @receiver.send( m, *@args, &@block ) : @receiver.send( m, *@args ) if @proxy_result.find {|a| @name.to_s =~ a } @value = permitter.proxy( @value, @allows, @proxy_result ) end rescue Exception @error = $! ensure @mutex.synchronize{ @finished = true @cv.signal } end end |
#wait ⇒ Object
リクエストの完了を待ち、結果を返す。
101 102 103 104 105 106 107 |
# File 'lib/jiji/agent/permitter.rb', line 101 def wait @mutex.synchronize{ @cv.wait( @mutex ) until @finished } raise @error if @error @value end |