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.



15
16
17
18
19
20
# File 'lib/riak/crdt/inner_map.rb', line 15

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

  initialize_collections
end

Instance Attribute Details

#countersObject (readonly)

Returns the value of attribute counters.



5
6
7
# File 'lib/riak/crdt/inner_map.rb', line 5

def counters
  @counters
end

#flagsObject (readonly)

Returns the value of attribute flags.



5
6
7
# File 'lib/riak/crdt/inner_map.rb', line 5

def flags
  @flags
end

#mapsObject (readonly)

Returns the value of attribute maps.



5
6
7
# File 'lib/riak/crdt/inner_map.rb', line 5

def maps
  @maps
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/riak/crdt/inner_map.rb', line 7

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.



12
13
14
# File 'lib/riak/crdt/inner_map.rb', line 12

def parent
  @parent
end

#registersObject (readonly)

Returns the value of attribute registers.



5
6
7
# File 'lib/riak/crdt/inner_map.rb', line 5

def registers
  @registers
end

#setsObject (readonly)

Returns the value of attribute sets.



5
6
7
# File 'lib/riak/crdt/inner_map.rb', line 5

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.



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

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

Instance Method Details

#context?Boolean

Returns:

  • (Boolean)


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

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.



23
24
25
26
27
28
29
30
# File 'lib/riak/crdt/inner_map.rb', line 23

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



32
33
34
35
36
37
38
39
40
# File 'lib/riak/crdt/inner_map.rb', line 32

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



42
43
44
# File 'lib/riak/crdt/inner_map.rb', line 42

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

#to_value_hObject Also known as: value



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

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