Class: Couchbase::Options::Analytics

Inherits:
Base
  • Object
show all
Defined in:
lib/couchbase/options.rb

Overview

Constant Summary collapse

DEFAULT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Analytics.new.freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#client_context, #parent_span, #retry_strategy, #timeout

Instance Method Summary collapse

Constructor Details

#initialize(client_context_id: nil, scan_consistency: nil, readonly: false, priority: nil, transcoder: JsonTranscoder.new, positional_parameters: nil, named_parameters: nil, scope_qualifier: nil, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) {|self| ... } ⇒ Analytics

Note:

Either positional_parameters or named_parameters may be specified.

Creates new instance of options for Cluster#analytics_query

Yield Parameters:

Raises:

  • (ArgumentError)


1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
# File 'lib/couchbase/options.rb', line 1930

def initialize(client_context_id: nil,
               scan_consistency: nil,
               readonly: false,
               priority: nil,
               transcoder: JsonTranscoder.new,
               positional_parameters: nil,
               named_parameters: nil,
               scope_qualifier: nil,
               timeout: nil,
               retry_strategy: nil,
               client_context: nil,
               parent_span: nil)
  raise ArgumentError, "Cannot pass positional and named parameters at the same time" if positional_parameters && named_parameters

  super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
  @client_context_id = client_context_id
  @scan_consistency = scan_consistency
  @readonly = readonly
  @priority = priority
  @transcoder = transcoder
  @positional_parameters = positional_parameters
  @named_parameters = named_parameters
  @scope_qualifier = scope_qualifier
  @raw_parameters = {}
  yield self if block_given?
end

Instance Attribute Details

#client_context_idString



1888
1889
1890
# File 'lib/couchbase/options.rb', line 1888

def client_context_id
  @client_context_id
end

#priorityBoolean



1891
1892
1893
# File 'lib/couchbase/options.rb', line 1891

def priority
  @priority
end

#readonlyBoolean



1890
1891
1892
# File 'lib/couchbase/options.rb', line 1890

def readonly
  @readonly
end

#scan_consistencySymbol



1889
1890
1891
# File 'lib/couchbase/options.rb', line 1889

def scan_consistency
  @scan_consistency
end

#scope_qualifierString



1893
1894
1895
# File 'lib/couchbase/options.rb', line 1893

def scope_qualifier
  @scope_qualifier
end

#transcoderJsonTranscoder, #decode(String)



1892
1893
1894
# File 'lib/couchbase/options.rb', line 1892

def transcoder
  @transcoder
end

Instance Method Details

#named_parameters(named) ⇒ Object

Sets named parameters for the query



1968
1969
1970
1971
# File 'lib/couchbase/options.rb', line 1968

def named_parameters(named)
  @named_parameters = named
  @positional_parameters = nil
end

#positional_parameters(positional) ⇒ Object

Sets positional parameters for the query



1960
1961
1962
1963
# File 'lib/couchbase/options.rb', line 1960

def positional_parameters(positional)
  @positional_parameters = positional
  @named_parameters = nil
end

#raw(key, value) ⇒ Object

Allows providing custom JSON key/value pairs for advanced usage



1977
1978
1979
# File 'lib/couchbase/options.rb', line 1977

def raw(key, value)
  @raw_parameters[key] = JSON.generate(value)
end

#to_backend(scope_name: nil, bucket_name: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
# File 'lib/couchbase/options.rb', line 1982

def to_backend(scope_name: nil, bucket_name: nil)
  {
    timeout: Utils::Time.extract_duration(@timeout),
    client_context_id: @client_context_id,
    scan_consistency: @scan_consistency,
    readonly: @readonly,
    priority: @priority,
    positional_parameters: export_positional_parameters,
    named_parameters: export_named_parameters,
    raw_parameters: @raw_parameters,
    scope_qualifier: @scope_qualifier,
    scope_name: scope_name,
    bucket_name: bucket_name,
  }
end