class HaveAPI::Resources::ActionState::Poll
Public Instance Methods
exec()
click to toggle source
# File lib/haveapi/resources/action_state.rb, line 100 def exec t = Time.now loop do state = @context.server.action_state.new( current_user, id: params[:action_state_id] ) error!('action state not found') unless state.valid? if state.finished? || (Time.now - t) >= input[:timeout] return state_to_hash(state) elsif input[:update_in] new_state = state_to_hash(state) %i[status current total].each do |v| return new_state if input[v] != new_state[v] end end return state_to_hash(state.poll(input)) if state.respond_to?(:poll) sleep(1) end end