Skip to content

Instantly share code, notes, and snippets.

@spickermann
Created February 20, 2013 15:38
Show Gist options
  • Save spickermann/4996428 to your computer and use it in GitHub Desktop.
Save spickermann/4996428 to your computer and use it in GitHub Desktop.
CouchbaseModel#count Hässlich wie die Nacht...
class Counter < Struct.new(:value)
def self.wrap(bucket, result)
new(result['value'])
end
end
view :count_all, :include_docs => false, :wrapper_class => Counter
def self.count
count_all.first.present? ? count_all.first.value : 0
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment