Class: Couchbase::Options::Decrement

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.

Decrement.new.freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#client_context, #parent_span, #retry_strategy, #timeout

Instance Method Summary collapse

Constructor Details

#initialize(delta: 1, initial: nil, expiry: nil, durability_level: :none, replicate_to: :none, persist_to: :none, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) {|self| ... } ⇒ Decrement

Creates an instance of options for BinaryCollection#decrement

Yield Parameters:

Raises:

  • (ArgumentError)


1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
# File 'lib/couchbase/options.rb', line 1499

def initialize(delta: 1,
               initial: nil,
               expiry: nil,
               durability_level: :none,
               replicate_to: :none,
               persist_to: :none,
               timeout: nil,
               retry_strategy: nil,
               client_context: nil,
               parent_span: nil)
  raise ArgumentError, "the delta cannot be less than 0" if delta.negative?

  super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
  @delta = delta
  @initial = initial
  @expiry = expiry
  if durability_level != :none && (replicate_to != :none || persist_to != :none)
    raise ArgumentError, "durability_level conflicts with replicate_to and persist_to options"
  end

  @persist_to = persist_to
  @replicate_to = replicate_to
  @durability_level = durability_level
  yield self if block_given?
end

Instance Attribute Details

#deltaInteger



1457
1458
1459
# File 'lib/couchbase/options.rb', line 1457

def delta
  @delta
end

#durability_levelSymbol



1460
1461
1462
# File 'lib/couchbase/options.rb', line 1460

def durability_level
  @durability_level
end

#expiryInteger, #in_seconds



1459
1460
1461
# File 'lib/couchbase/options.rb', line 1459

def expiry
  @expiry
end

#initialInteger



1458
1459
1460
# File 'lib/couchbase/options.rb', line 1458

def initial
  @initial
end

Instance Method Details

#to_backendObject

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.



1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
# File 'lib/couchbase/options.rb', line 1533

def to_backend
  {
    timeout: Utils::Time.extract_duration(@timeout),
    delta: @delta,
    initial_value: @initial,
    expiry: Utils::Time.extract_expiry_time(@expiry),
    durability_level: @durability_level,
    persist_to: @persist_to,
    replicate_to: @replicate_to,
  }
end