lib/em-synchrony/em-remcached.rb in em-synchrony-0.1.4 vs lib/em-synchrony/em-remcached.rb in em-synchrony-0.1.5

- old
+ new

@@ -1,6 +1,10 @@ -require "remcached" +begin + require "remcached" +rescue LoadError => error + raise "Missing EM-Synchrony dependency: gem install remcached" +end module Memcached class << self def connect(servers) @@ -43,22 +47,22 @@ %w[add get set delete].each do |type| class_eval %[ def amulti_#{type}(contents, &callback) df = EventMachine::DefaultDeferrable.new df.callback &callback - + cb = Proc.new { |res| df.succeed(res) } multi_operation Request::#{type.capitalize}, contents, &cb - + df end - + def multi_#{type}(contents, &callback) fiber = Fiber.current - + df = amulti_#{type}(contents, &Proc.new { |res| fiber.resume(res) }) df.callback &callback - + Fiber.yield end ] end