Class: Couchbase::MutateInSpec
- Inherits:
-
Object
- Object
- Couchbase::MutateInSpec
- Defined in:
- lib/couchbase/subdoc.rb,
/Users/sergey.auseyau/code/couchbase-ruby-client/lib/couchbase/subdoc.rb more...
Constant Summary collapse
- CAS =
"${Mutation.CAS}".freeze
- SEQ_NO =
"${Mutation.seqno}".freeze
- VALUE_CRC32C =
"${Mutation.value_crc32c}".freeze
Instance Attribute Summary collapse
-
#param ⇒ Object
readonly
Returns the value of attribute param.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.array_add_unique(path, value) ⇒ MutateInSpec
Creates a command with the intent of inserting a value into an existing JSON array, but only if the value is not already contained in the array (by way of string comparison).
-
.array_append(path, values) ⇒ MutateInSpec
Creates a command with the intention of appending a value to an existing JSON array.
-
.array_insert(path, values) ⇒ MutateInSpec
Creates a command with the intention of inserting a value into an existing JSON array.
-
.array_prepend(path, values) ⇒ MutateInSpec
Creates a command with the intention of prepending a value to an existing JSON array.
-
.decrement(path, delta) ⇒ MutateInSpec
Creates a command with the intent of decrementing a numerical field in a JSON object.
-
.increment(path, delta) ⇒ MutateInSpec
Creates a command with the intent of incrementing a numerical field in a JSON object.
-
.insert(path, value) ⇒ MutateInSpec
Creates a command with the intention of inserting a new value in a JSON object.
-
.remove(path) ⇒ MutateInSpec
Creates a command with the intention of removing an existing value in a JSON object.
-
.replace(path, value) ⇒ MutateInSpec
Creates a command with the intention of replacing an existing value in a JSON document.
-
.upsert(path, value) ⇒ MutateInSpec
Creates a command with the intention of upserting a value in a JSON object.
Instance Method Summary collapse
- #create_path ⇒ Object
- #create_path? ⇒ Boolean
- #expand_macros? ⇒ Boolean
- #xattr ⇒ Object
- #xattr? ⇒ Boolean
Instance Attribute Details
#param ⇒ Object (readonly)
Returns the value of attribute param.
254 255 256 |
# File 'lib/couchbase/subdoc.rb', line 254 def param @param end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
253 254 255 |
# File 'lib/couchbase/subdoc.rb', line 253 def path @path end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
252 253 254 |
# File 'lib/couchbase/subdoc.rb', line 252 def type @type end |
Class Method Details
.array_add_unique(path, value) ⇒ MutateInSpec
Creates a command with the intent of inserting a value into an existing JSON array, but only if the value is not already contained in the array (by way of string comparison).
Will error if the last element of the path does not exist or is not an array.
198 199 200 |
# File 'lib/couchbase/subdoc.rb', line 198 def self.array_add_unique(path, value) new(:array_add_unique, path, value) end |
.array_append(path, values) ⇒ MutateInSpec
Creates a command with the intention of appending a value to an existing JSON array.
Will error if the last element of the path does not exist or is not an array.
161 162 163 |
# File 'lib/couchbase/subdoc.rb', line 161 def self.array_append(path, values) new(:array_push_last, path, values) end |
.array_insert(path, values) ⇒ MutateInSpec
Creates a command with the intention of inserting a value into an existing JSON array.
Will error if the last element of the path does not exist or is not an array.
185 186 187 |
# File 'lib/couchbase/subdoc.rb', line 185 def self.array_insert(path, values) new(:array_insert, path, values) end |
.array_prepend(path, values) ⇒ MutateInSpec
Creates a command with the intention of prepending a value to an existing JSON array.
Will error if the last element of the path does not exist or is not an array.
173 174 175 |
# File 'lib/couchbase/subdoc.rb', line 173 def self.array_prepend(path, values) new(:array_push_first, path, values) end |
.decrement(path, delta) ⇒ MutateInSpec
Creates a command with the intent of decrementing a numerical field in a JSON object.
If the field does not exist, then it is created and takes the value of delta
* -1
222 223 224 |
# File 'lib/couchbase/subdoc.rb', line 222 def self.decrement(path, delta) new(:counter, path, -1 * delta.abs) end |
.increment(path, delta) ⇒ MutateInSpec
Creates a command with the intent of incrementing a numerical field in a JSON object.
If the field does not exist, then it is created and takes the value of delta
210 211 212 |
# File 'lib/couchbase/subdoc.rb', line 210 def self.increment(path, delta) new(:counter, path, delta.abs) end |
.insert(path, value) ⇒ MutateInSpec
Creates a command with the intention of inserting a new value in a JSON object.
Will error if the last element of the path already exists.
125 126 127 |
# File 'lib/couchbase/subdoc.rb', line 125 def self.insert(path, value) new(:dict_add, path, value) end |
.remove(path) ⇒ MutateInSpec
Creates a command with the intention of removing an existing value in a JSON object.
Will error if the path does not exist.
136 137 138 |
# File 'lib/couchbase/subdoc.rb', line 136 def self.remove(path) new(:remove, path, nil) end |
.replace(path, value) ⇒ MutateInSpec
Creates a command with the intention of replacing an existing value in a JSON document.
If the path is empty (“”), then the value will be used for the document’s full body. Will error if the last element of the path does not exist.
112 113 114 |
# File 'lib/couchbase/subdoc.rb', line 112 def self.replace(path, value) new(path.empty? ? :set_doc : :replace, path, value) end |
.upsert(path, value) ⇒ MutateInSpec
Creates a command with the intention of upserting a value in a JSON object.
That is, the value will be replaced if the path already exists, or inserted if not.
149 150 151 |
# File 'lib/couchbase/subdoc.rb', line 149 def self.upsert(path, value) new(:dict_upsert, path, value) end |
Instance Method Details
#create_path ⇒ Object
[View source]
231 232 233 234 |
# File 'lib/couchbase/subdoc.rb', line 231 def create_path @create_path = true self end |
#create_path? ⇒ Boolean
240 241 242 |
# File 'lib/couchbase/subdoc.rb', line 240 def create_path? @create_path end |
#expand_macros? ⇒ Boolean
244 245 246 |
# File 'lib/couchbase/subdoc.rb', line 244 def @expand_macros end |
#xattr ⇒ Object
[View source]
226 227 228 229 |
# File 'lib/couchbase/subdoc.rb', line 226 def xattr @xattr = true self end |
#xattr? ⇒ Boolean
236 237 238 |
# File 'lib/couchbase/subdoc.rb', line 236 def xattr? @xattr end |