class ActiveRecord::Promise
Public Instance Methods
Source
# File lib/active_record/promise.rb, line 13 def pending? @future_result.pending? end
Returns whether the associated query is still being executed or not.
Source
# File lib/active_record/promise.rb, line 36 def then(&block) Promise.new(@future_result, @block ? @block >> block : block) end
Returns a new ActiveRecord::Promise that will apply the passed block when the value is accessed:
Post.async_pick(:title).then { |title| title.upcase }.value # => "POST TITLE"
Source
# File lib/active_record/promise.rb, line 20 def value return @value if defined? @value result = @future_result.result @value = if @block @block.call(result) else result end end
Private Instance Methods
Source
# File lib/active_record/promise.rb, line 53 def status if @future_result.pending? :pending elsif @future_result.canceled? :canceled else :complete end end