lib/couchbase/scope.rb in couchbase-3.0.3 vs lib/couchbase/scope.rb in couchbase-3.1.0

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright 2020-2021 Couchbase, Inc. +# Copyright 2020-2021 Couchbase, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. require "couchbase/collection" require "couchbase/query_options" +require "couchbase/analytics_options" module Couchbase # The scope identifies a group of collections and allows high application density as a result. class Scope attr_reader :bucket_name @@ -76,11 +77,11 @@ metrics.mutation_count = resp[:meta][:metrics][:mutation_count] metrics.error_count = resp[:meta][:metrics][:error_count] metrics.warning_count = resp[:meta][:metrics][:warning_count] end end - res[:warnings] = resp[:warnings].map { |warn| QueryWarning.new(warn[:code], warn[:message]) } if resp[:warnings] + res[:warnings] = resp[:warnings].map { |warn| Cluster::QueryWarning.new(warn[:code], warn[:message]) } if resp[:warnings] end res.instance_variable_set("@rows", resp[:rows]) end end @@ -97,29 +98,29 @@ # # @return [AnalyticsResult] def analytics_query(statement, options = Options::Analytics.new) resp = @backend.document_analytics(statement, options.to_backend(scope_name: @name, bucket_name: @bucket_name)) - AnalyticsResult.new do |res| + Cluster::AnalyticsResult.new do |res| res.transcoder = options.transcoder - res.meta_data = AnalyticsMetaData.new do |meta| + res.meta_data = Cluster::AnalyticsMetaData.new do |meta| meta.status = resp[:meta][:status] meta.request_id = resp[:meta][:request_id] meta.client_context_id = resp[:meta][:client_context_id] meta.signature = JSON.parse(resp[:meta][:signature]) if resp[:meta][:signature] meta.profile = JSON.parse(resp[:meta][:profile]) if resp[:meta][:profile] - meta.metrics = AnalyticsMetrics.new do |metrics| + meta.metrics = Cluster::AnalyticsMetrics.new do |metrics| if resp[:meta][:metrics] metrics.elapsed_time = resp[:meta][:metrics][:elapsed_time] metrics.execution_time = resp[:meta][:metrics][:execution_time] metrics.result_count = resp[:meta][:metrics][:result_count] metrics.result_size = resp[:meta][:metrics][:result_size] metrics.error_count = resp[:meta][:metrics][:error_count] metrics.warning_count = resp[:meta][:metrics][:warning_count] metrics.processed_objects = resp[:meta][:metrics][:processed_objects] end end - res[:warnings] = resp[:warnings].map { |warn| QueryWarning.new(warn[:code], warn[:message]) } if resp[:warnings] + res[:warnings] = resp[:warnings].map { |warn| Cluster::AnalyticsWarning.new(warn[:code], warn[:message]) } if resp[:warnings] end res.instance_variable_set("@rows", resp[:rows]) end end end