Permalink
Browse files

simple Model, with instance level async_update

  • Loading branch information...
1 parent 385883a commit dc858a5ca8f9ca0f421c932c84086da97caea2d5 @tmm1 committed Dec 7, 2008
Showing with 17 additions and 27 deletions.
  1. +17 −27 lib/sequel/async.rb
View
@@ -101,26 +101,24 @@ def async_count &cb
end
class Model
- class << self
- # async version of Model#insert
- def async_insert *args, &cb
- dataset.async_insert(*args, &cb)
- end
-
- # async version of Dataset#insert_multi
- def async_multi_insert *args, &cb
- dataset.async_multi_insert(*args, &cb)
- end
-
- # async version of Model#each
- def async_each &cb
- dataset.async_each(&cb)
- end
+ def async_update *args, &cb
+ this.async_update(*args, &cb)
+ set(*args)
+ self
+ end
- # async version of Model#all
- # yields an array
- def async_all &cb
- dataset.async_all(&cb)
+ class << self
+ [ :async_insert,
+ :async_multi_insert,
+ :async_each,
+ :async_all,
+ :async_update,
+ :async_count ].each do |method|
+ class_eval %[
+ def #{method} *args, &cb
+ dataset.#{method}(*args, &cb)
+ end
+ ]
end
# async version of Model#[]
@@ -138,14 +136,6 @@ def async_lookup args
}
nil
end
-
- def async_update *args, &cb
- dataset.async_update(*args, &cb)
- end
-
- def async_count &cb
- dataset.async_count(&cb)
- end
end
end
end

0 comments on commit dc858a5

Please sign in to comment.