Skip to content

Commit

Permalink
simple Model, with instance level async_update
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Dec 7, 2008
1 parent 385883a commit dc858a5
Showing 1 changed file with 17 additions and 27 deletions.
44 changes: 17 additions & 27 deletions lib/sequel/async.rb
Expand Up @@ -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#[]
Expand All @@ -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.