From 3136377fef22956071b3eb567ec9a2b1be66af32 Mon Sep 17 00:00:00 2001 From: Giallombardo Nathan Date: Mon, 1 Jul 2024 15:38:44 +0000 Subject: [PATCH] add Views::design_document doc --- lib/couchbase-orm/views.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/couchbase-orm/views.rb b/lib/couchbase-orm/views.rb index dabbf857..e1b1c07d 100644 --- a/lib/couchbase-orm/views.rb +++ b/lib/couchbase-orm/views.rb @@ -158,6 +158,25 @@ def self.#{find_method}(#{attr}) ", __FILE__, __LINE__ - 4 end + # Ensures that the Couchbase design document is up-to-date with the defined views. + # + # This method checks the current state of the design document in the Couchbase bucket + # and updates it if there are any discrepancies with the views defined in the current class. + # + # @return [Boolean] `true` if the design document was updated, `false` otherwise. + # + # @raise [Couchbase::Error::DesignDocumentNotFound] if the design document is not found. + # + # @example Ensure the design document is up-to-date + # class User + # include CouchbaseOrm::Model + # + # view :by_email, emit_key: :email + # view :by_username, emit_key: :username + # end + # + # # This will check the current design document for discrepancies and update if needed + # User.ensure_design_document! def ensure_design_document! return false unless @views && !@views.empty?