def view(spec)
      results = CouchPotato::View::ViewQuery.new(
        couchrest_database,
        spec.design_document,
        {spec.view_name => {
          :map => spec.map_function,
          :reduce => spec.reduce_function
        }
        },
        ({spec.list_name => spec.list_function} unless spec.list_name.nil?),
        spec.lib,
        spec.language
      ).query_view!(spec.view_parameters)
      processed_results = spec.process_results results
      processed_results.each do |document|
        document.database = self if document.respond_to?(:database=)
      end if processed_results.respond_to?(:each)
      processed_results
    end
def view(spec)
      results = CouchPotato::View::ViewQuery.new(
        couchrest_database,
        spec.design_document,
        {spec.view_name => {
          :map => spec.map_function,
          :reduce => spec.reduce_function
        }
        },
        ({spec.list_name => spec.list_function} unless spec.list_name.nil?),
        spec.lib,
        spec.language
      ).query_view!(spec.view_parameters)
      processed_results = spec.process_results results
      processed_results.each do |document|
        document.database = self if document.respond_to?(:database=)
      end if processed_results.respond_to?(:each)
      processed_results
    end
executes a view and return the results. you pass in a view spec
 which is usually a result of a SomePersistentClass.some_view call.

 Example:

   class User
     include CouchPotato::Persistence
     property :age
     view :all, key: :age
   end
   db = CouchPotato.database

   db.view(User.all) # => [user1, user2]

 You can pass the usual parameters you can pass to a couchdb view to the view:

   db.view(User.all(limit: 5, startkey: 2, reduce: false))

 For your convenience when passing a hash with only a key parameter you can just pass in the value

   db.view(User.all(key: 1)) == db.view(User.all(1))

 Instead of passing a startkey and endkey you can pass in a key with a range:

   db.view(User.all(key: 1..20)) == db.view(startkey: 1, endkey: 20) == db.view(User.all(1..20))

 You can also pass in multiple keys:

   db.view(User.all(keys: [1, 2, 3]))