Navigation Menu

Skip to content

Commit

Permalink
Revert "Make Deferrable module to accept multiple "on_ready" callbacks"
Browse files Browse the repository at this point in the history
This reverts commit e8e0e23.
Because it is too complex.
  • Loading branch information
piroor committed Apr 21, 2015
1 parent 7c8b85e commit 169f12a
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions lib/droonga/deferrable.rb
Expand Up @@ -15,31 +15,17 @@

module Droonga
module Deferrable
attr_writer :on_failure
attr_writer :on_ready, :on_failure

def wait_until_ready(target)
target.on_ready = lambda do
on_ready
end
end

def on_ready=(callback)
@on_ready_callbacks ||= []
if callback
@on_ready_callbacks << callback
else
@on_ready_callbacks.clear
end
callback
end

private
def on_ready
if @on_ready_callbacks
@on_ready_callbacks.each do |callback|
callback.call
end
end
@on_ready.call if @on_ready
end

def on_failure
Expand Down

0 comments on commit 169f12a

Please sign in to comment.