Skip to content

Commit

Permalink
Merge pull request #96 from Mapotempo/add_yarddoc
Browse files Browse the repository at this point in the history
add Views::design_document doc
  • Loading branch information
giallon authored Jul 1, 2024
2 parents 3f6247d + 3136377 commit 61452e8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/couchbase-orm/views.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down

0 comments on commit 61452e8

Please sign in to comment.