Adding support for find_by quick view access searches

This commit is contained in:
Sam Lown 2010-06-15 01:15:30 +02:00
parent 72fe43d64a
commit 5dfd18cd71
3 changed files with 33 additions and 4 deletions

View file

@ -129,10 +129,15 @@ module CouchRest
def self.method_missing(m, *args, &block)
if has_view?(m)
query = args.shift || {}
view(m, query, *args, &block)
else
super
return view(m, query, *args, &block)
elsif m.to_s =~ /^find_(.+)/
view_name = $1
if has_view?(view_name)
query = {:key => args.first, :limit => 1}
return view(view_name, query).first
end
end
super
end
### instance methods