Class: Riak::Crdt::InnerMap

Inherits:
Object show all
Defined in:
lib/riak/crdt/inner_map.rb

Overview

A map that exists inside a TypedCollection inside another map.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, value = {}) ⇒ InnerMap

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 a new instance of InnerMap.



29
30
31
32
33
34
# File 'lib/riak/crdt/inner_map.rb', line 29

def initialize(parent, value = {})
  @parent = parent
  @value = value.symbolize_keys

  initialize_collections
end

Instance Attribute Details

#countersObject (readonly)

Returns the value of attribute counters.



19
20
21
# File 'lib/riak/crdt/inner_map.rb', line 19

def counters
  @counters
end

#flagsObject (readonly)

Returns the value of attribute flags.



19
20
21
# File 'lib/riak/crdt/inner_map.rb', line 19

def flags
  @flags
end

#mapsObject (readonly)

Returns the value of attribute maps.



19
20
21
# File 'lib/riak/crdt/inner_map.rb', line 19

def maps
  @maps
end

#nameObject

Returns the value of attribute name.



21
22
23
# File 'lib/riak/crdt/inner_map.rb', line 21

def name
  @name
end

#parentObject (readonly)

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.

The parent of this counter.



26
27
28
# File 'lib/riak/crdt/inner_map.rb', line 26

def parent
  @parent
end

#registersObject (readonly)

Returns the value of attribute registers.



19
20
21
# File 'lib/riak/crdt/inner_map.rb', line 19

def registers
  @registers
end

#setsObject (readonly)

Returns the value of attribute sets.



19
20
21
# File 'lib/riak/crdt/inner_map.rb', line 19

def sets
  @sets
end

Class Method Details

.deleteObject

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.



69
70
71
72
73
# File 'lib/riak/crdt/inner_map.rb', line 69

def self.delete
  Operation::Delete.new.tap do |op|
    op.type = :map
  end
end

Instance Method Details

#context?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/riak/crdt/inner_map.rb', line 75

def context?
  @parent.context?
end

#operate(inner_operation) ⇒ 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.



37
38
39
40
41
42
43
44
# File 'lib/riak/crdt/inner_map.rb', line 37

def operate(inner_operation)
  wrapped_operation = Operation::Update.new.tap do |op|
    op.value = inner_operation
    op.type = :map
  end

  @parent.operate(name, wrapped_operation)
end

#pretty_print(pp) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/riak/crdt/inner_map.rb', line 46

def pretty_print(pp)
  pp.object_group self do
    %w{counters flags maps registers sets}.each do |h|
      pp.comma_breakable
      pp.text "#{h}="
      pp.pp send h
    end
  end
end

#pretty_print_cycle(pp) ⇒ Object



56
57
58
# File 'lib/riak/crdt/inner_map.rb', line 56

def pretty_print_cycle(pp)
  pp.text "InnerMap"
end

#to_value_hObject Also known as: value



60
61
62
63
64
# File 'lib/riak/crdt/inner_map.rb', line 60

def to_value_h
  %w{counters flags maps registers sets}.map do |k|
    [k, send(k).to_value_h]
  end.to_h
end