Class: Aerospike::Node::Generation

Inherits:
Object
  • Object
show all
Defined in:
lib/aerospike/node/generation.rb

Overview

generic class for representing changes in eg. peer and partition generation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number = -1)) ⇒ Generation

Returns a new instance of Generation.



26
27
28
29
# File 'lib/aerospike/node/generation.rb', line 26

def initialize(number = -1)
  @number = ::Aerospike::Atomic.new(number)
  @changed = ::Aerospike::Atomic.new(false)
end

Instance Attribute Details

#numberObject (readonly)

Returns the value of attribute number.



24
25
26
# File 'lib/aerospike/node/generation.rb', line 24

def number
  @number
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/aerospike/node/generation.rb', line 31

def changed?
  @changed.value == true
end

#eql?(number) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/aerospike/node/generation.rb', line 35

def eql?(number)
  @number.value == number
end

#reset_changed!Object



39
40
41
# File 'lib/aerospike/node/generation.rb', line 39

def reset_changed!
  @changed.value = false
end

#update(new_number) ⇒ Object



43
44
45
46
47
# File 'lib/aerospike/node/generation.rb', line 43

def update(new_number)
  return if @number.value == new_number
  @number.value = new_number
  @changed.value = true
end