lib/couchrest/model/proxyable.rb in couchrest_model-1.1.0.beta2 vs lib/couchrest/model/proxyable.rb in couchrest_model-1.1.0.beta3
- old
+ new
@@ -46,19 +46,18 @@
@owner_name = owner_name
@database = database
end
# Base
-
def new(*args)
proxy_update(model.new(*args))
end
def build_from_database(doc = {})
proxy_update(model.build_from_database(doc))
end
-
+
def method_missing(m, *args, &block)
if has_view?(m)
if model.respond_to?(m)
return model.send(m, *args).proxy(self)
else
@@ -71,63 +70,58 @@
return first_from_view(view_name, *args)
end
end
super
end
-
+
# DocumentQueries
-
+
def all(opts = {}, &block)
proxy_update_all(@model.all({:database => @database}.merge(opts), &block))
end
-
+
def count(opts = {})
@model.count({:database => @database}.merge(opts))
end
-
+
def first(opts = {})
proxy_update(@model.first({:database => @database}.merge(opts)))
end
-
+
def last(opts = {})
proxy_update(@model.last({:database => @database}.merge(opts)))
end
-
+
def get(id)
proxy_update(@model.get(id, @database))
end
alias :find :get
-
+
# Views
-
+
def has_view?(view)
@model.has_view?(view)
end
def view_by(*args)
@model.view_by(*args)
end
-
+
def view(name, query={}, &block)
proxy_update_all(@model.view(name, {:database => @database}.merge(query), &block))
end
-
+
def first_from_view(name, *args)
# add to first hash available, or add to end
(args.last.is_a?(Hash) ? args.last : (args << {}).last)[:database] = @database
proxy_update(@model.first_from_view(name, *args))
end
-
+
# DesignDoc
-
def design_doc
@model.design_doc
end
-
- def refresh_design_doc(db = nil)
- @model.refresh_design_doc(db || @database)
- end
-
+
def save_design_doc(db = nil)
@model.save_design_doc(db || @database)
end