lib/rira/base.rb in lackac-rira-0.0.2 vs lib/rira/base.rb in lackac-rira-0.0.3

- old
+ new

@@ -38,15 +38,16 @@ :logout => [nil, "logout"], } def method_missing(method, *args) model, *methods = MAPPINGS[method] - + super(method, *args) if methods.empty? + retried = false begin - case result = xmlrpc_client.call("jira1.#{methods.shift}", @token, *args) + case result = xmlrpc_client.call("jira1.#{methods.first}", @token, *args) when Hash model_or_struct(model, result) when Array result.map do |item| if item.is_a?(Hash) @@ -57,11 +58,18 @@ end else result end rescue XMLRPC::FaultException => e - retry unless methods.empty? - raise RPCError.new(e) + if e.faultString =~ /session timed out/ and not retried + @token = xmlrpc_client.call("jira1.login", @username, @password) + retried = true + retry + else + methods.shift + retry unless methods.empty? + raise RPCError.new(e) + end end end private