Class: Couchbase::BinaryCollection
- Inherits:
-
Object
- Object
- Couchbase::BinaryCollection
- Defined in:
- lib/couchbase/binary_collection.rb,
lib/couchbase/binary_collection_options.rb,
/Users/sergey.auseyau/code/couchbase-ruby-client/lib/couchbase/binary_collection.rb,
/Users/sergey.auseyau/code/couchbase-ruby-client/lib/couchbase/binary_collection_options.rb more...
Defined Under Namespace
Classes: CounterResult
Instance Method Summary collapse
-
#append(id, content, options = Options::Append.new) ⇒ Collection::MutationResult
Appends binary content to the document.
-
#decrement(id, options = Options::Decrement.new) ⇒ CounterResult
Decrements the counter document by one of the number defined in the options.
-
#increment(id, options = Options::Increment.new) ⇒ CounterResult
Increments the counter document by one of the number defined in the options.
-
#initialize(collection) ⇒ BinaryCollection
constructor
A new instance of BinaryCollection.
-
#prepend(id, content, options = Options::Prepend.new) ⇒ Collection::MutationResult
Prepends binary content to the document.
Constructor Details
#initialize(collection) ⇒ BinaryCollection
Returns a new instance of BinaryCollection.
23 24 25 26 |
# File 'lib/couchbase/binary_collection.rb', line 23 def initialize(collection) @collection = collection @backend = collection.instance_variable_get("@backend") end |
Instance Method Details
#append(id, content, options = Options::Append.new) ⇒ Collection::MutationResult
Appends binary content to the document
40 41 42 43 44 45 46 47 |
# File 'lib/couchbase/binary_collection.rb', line 40 def append(id, content, = Options::Append.new) resp = @backend.document_append(@collection.bucket_name, "#{@collection.scope_name}.#{@collection.name}", id, content, .to_backend) Collection::MutationResult.new do |res| res.cas = resp[:cas] res.mutation_token = @collection.send(:extract_mutation_token, resp) end end |
#decrement(id, options = Options::Decrement.new) ⇒ CounterResult
Decrements the counter document by one of the number defined in the options
104 105 106 107 108 109 110 111 112 |
# File 'lib/couchbase/binary_collection.rb', line 104 def decrement(id, = Options::Decrement.new) resp = @backend.document_decrement(@collection.bucket_name, "#{@collection.scope_name}.#{@collection.name}", id, .to_backend) CounterResult.new do |res| res.cas = resp[:cas] res.content = resp[:content] res.mutation_token = @collection.send(:extract_mutation_token, resp) end end |
#increment(id, options = Options::Increment.new) ⇒ CounterResult
Increments the counter document by one of the number defined in the options
82 83 84 85 86 87 88 89 90 |
# File 'lib/couchbase/binary_collection.rb', line 82 def increment(id, = Options::Increment.new) resp = @backend.document_increment(@collection.bucket_name, "#{@collection.scope_name}.#{@collection.name}", id, .to_backend) CounterResult.new do |res| res.cas = resp[:cas] res.content = resp[:content] res.mutation_token = @collection.send(:extract_mutation_token, resp) end end |
#prepend(id, content, options = Options::Prepend.new) ⇒ Collection::MutationResult
Prepends binary content to the document
61 62 63 64 65 66 67 68 |
# File 'lib/couchbase/binary_collection.rb', line 61 def prepend(id, content, = Options::Prepend.new) resp = @backend.document_prepend(@collection.bucket_name, "#{@collection.scope_name}.#{@collection.name}", id, content, .to_backend) Collection::MutationResult.new do |res| res.cas = resp[:cas] res.mutation_token = @collection.send(:extract_mutation_token, resp) end end |