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
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -101,26 +101,24 @@ def async_count &cb
end end


class Model class Model
class << self def async_update *args, &cb
# async version of Model#insert this.async_update(*args, &cb)
def async_insert *args, &cb set(*args)
dataset.async_insert(*args, &cb) self
end 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


# async version of Model#all class << self
# yields an array [ :async_insert,
def async_all &cb :async_multi_insert,
dataset.async_all(&cb) :async_each,
:async_all,
:async_update,
:async_count ].each do |method|
class_eval %[
def #{method} *args, &cb
dataset.#{method}(*args, &cb)
end
]
end end


# async version of Model#[] # async version of Model#[]
Expand All @@ -138,14 +136,6 @@ def async_lookup args
} }
nil nil
end end

def async_update *args, &cb
dataset.async_update(*args, &cb)
end

def async_count &cb
dataset.async_count(&cb)
end
end end
end end
end end

0 comments on commit dc858a5

Please sign in to comment.