class Deferred::Promise

Public Class Methods

new(deferred) click to toggle source

@param deferred [Deferred]

# File lib/deferred/promise.rb, line 5
def initialize(deferred)
  deferred
  [:done, :fail, :progress, :always].each do |action|
    define_singleton_method(action) do |*args, &block|
      deferred.send(action, *args, &block)
      self
    end
  end
  [:state, :then, :pipe].each do |action|
    define_singleton_method(action) do |*args, &block|
      deferred.send(action, *args, &block)
    end
  end
end

Public Instance Methods

promise() click to toggle source

Returns the self @return [Promise] self

# File lib/deferred/promise.rb, line 22
def promise
  self
end