Class: Couchbase::Options::Get
Overview
Options for Collection#get
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.
Get.new.freeze
Instance Attribute Summary collapse
-
#preserve_array_indexes ⇒ Boolean
private
Whether to use sparse arrays (default
false
). -
#projections ⇒ Array<String>
private
List of paths to project.
- #transcoder ⇒ JsonTranscoder, #decode(String, Integer)
- #with_expiry ⇒ Boolean
Attributes inherited from Base
#client_context, #parent_span, #retry_strategy, #timeout
Instance Method Summary collapse
-
#initialize(projections: [], with_expiry: false, transcoder: JsonTranscoder.new, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) {|self| ... } ⇒ Get
constructor
Creates an instance of options for Collection#get.
- #need_projected_get? ⇒ Boolean private
-
#project(*paths) ⇒ Object
Allows to specify a custom list paths to fetch from the document instead of the whole.
- #to_backend ⇒ Object private
Constructor Details
#initialize(projections: [], with_expiry: false, transcoder: JsonTranscoder.new, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) {|self| ... } ⇒ Get
Creates an instance of options for Collection#get
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/couchbase/options.rb', line 71 def initialize(projections: [], with_expiry: false, transcoder: JsonTranscoder.new, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span) @projections = projections @with_expiry = with_expiry @transcoder = transcoder @preserve_array_indexes = false yield self if block_given? end |
Instance Attribute Details
#preserve_array_indexes ⇒ Boolean
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.
Returns whether to use sparse arrays (default false
).
99 100 101 |
# File 'lib/couchbase/options.rb', line 99 def preserve_array_indexes @preserve_array_indexes end |
#projections ⇒ Array<String>
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.
Returns list of paths to project.
103 104 105 |
# File 'lib/couchbase/options.rb', line 103 def projections @projections end |
#transcoder ⇒ JsonTranscoder, #decode(String, Integer)
57 58 59 |
# File 'lib/couchbase/options.rb', line 57 def transcoder @transcoder end |
#with_expiry ⇒ Boolean
56 57 58 |
# File 'lib/couchbase/options.rb', line 56 def with_expiry @with_expiry end |
Instance Method Details
#need_projected_get? ⇒ Boolean
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.
107 108 109 |
# File 'lib/couchbase/options.rb', line 107 def need_projected_get? @with_expiry || !@projections&.empty? end |
#project(*paths) ⇒ Object
Allows to specify a custom list paths to fetch from the document instead of the whole.
Note that a maximum of 16 individual paths can be projected at a time due to a server limitation. If you need more than that, think about fetching less-generic paths or the full document straight away.
92 93 94 95 |
# File 'lib/couchbase/options.rb', line 92 def project(*paths) @projections ||= [] @projections |= paths.flatten # union with current projections end |
#to_backend ⇒ 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.
112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/couchbase/options.rb', line 112 def to_backend = { timeout: Utils::Time.extract_duration(@timeout), } .update(with_expiry: true) if @with_expiry unless @projections&.empty? .update({ projections: @projections, preserve_array_indexes: @preserve_array_indexes, }) end end |