Class: Riak::Crdt::Base Private
- Includes:
- Util::Translation
- Defined in:
- lib/riak/crdt/base.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Basic and shared code used by the top-level CRDTs. In particular, dirty- tracking, loading, and operating is implemented by this class, and the Set, HyperLogLog, Counter, and Map classes implement everything else.
Direct Known Subclasses
Counter, HyperLogLog, Map, Set
Instance Attribute Summary collapse
- #bucket ⇒ Object readonly private
- #bucket_type ⇒ Object readonly private
-
#key ⇒ Object
readonly
private
Returns the key of this CRDT.
Instance Method Summary collapse
- #==(other) ⇒ Object private
-
#context? ⇒ Boolean
private
Does this CRDT have the context necessary to remove elements?.
- #dirty? ⇒ Boolean private
-
#initialize(bucket, key, bucket_type, options = {}) ⇒ Base
constructor
private
Base CRDT initialization The bucket type is determined by the first of these sources:.
- #inspect_name ⇒ Object private
- #pretty_print(pp) ⇒ Object private
- #pretty_print_cycle(pp) ⇒ Object private
-
#reload ⇒ Object
private
Force a reload of this structure from Riak.
Methods included from Util::Translation
Constructor Details
#initialize(bucket, key, bucket_type, options = {}) ⇒ Base
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.
Base CRDT initialization The bucket type is determined by the first of these sources:
-
The ‘bucket_type` String argument
-
A BucketTyped::Bucket as the ‘bucket` argument
-
A ‘bucket_type` Symbol argument is looked up in the `Crdt::Base::DEFAULT_BUCKET_TYPES` hash
33 34 35 36 37 38 39 40 |
# File 'lib/riak/crdt/base.rb', line 33 def initialize(bucket, key, bucket_type, = {}) configure_bucket bucket configure_key key configure_bucket_type bucket_type @options = @dirty = true end |
Instance Attribute Details
#bucket ⇒ Object (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.
11 12 13 |
# File 'lib/riak/crdt/base.rb', line 11 def bucket @bucket end |
#bucket_type ⇒ Object (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.
12 13 14 |
# File 'lib/riak/crdt/base.rb', line 12 def bucket_type @bucket_type end |
#key ⇒ Object (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.
Returns the key of this CRDT. Extremely useful when using a Riak-assigned key.
16 17 18 |
# File 'lib/riak/crdt/base.rb', line 16 def key @key end |
Instance Method Details
#==(other) ⇒ 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.
64 65 66 67 68 69 70 |
# File 'lib/riak/crdt/base.rb', line 64 def ==(other) return false unless self.class == other.class return false unless self.bucket_type == other.bucket_type return false unless self.bucket == other.bucket return false unless self.key == other.key return true end |
#context? ⇒ Boolean
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.
Does this CRDT have the context necessary to remove elements?
60 61 62 |
# File 'lib/riak/crdt/base.rb', line 60 def context? !!@context end |
#dirty? ⇒ Boolean
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.
42 43 44 |
# File 'lib/riak/crdt/base.rb', line 42 def dirty? @dirty end |
#inspect_name ⇒ 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.
92 93 94 95 |
# File 'lib/riak/crdt/base.rb', line 92 def inspect_name "#<#{self.class.name} bucket=#{@bucket.name} " \ "key=#{@key} type=#{@bucket_type}>" end |
#pretty_print(pp) ⇒ 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.
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/riak/crdt/base.rb', line 72 def pretty_print(pp) pp.object_group self do pp.breakable pp.text "bucket_type=#{@bucket_type}" pp.comma_breakable pp.text "bucket=#{@bucket.name}" pp.comma_breakable pp.text "key=#{@key}" yield end end |
#pretty_print_cycle(pp) ⇒ 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.
85 86 87 88 89 90 |
# File 'lib/riak/crdt/base.rb', line 85 def pretty_print_cycle(pp) pp.object_group self do pp.breakable pp.text "#{@bucket_type}/#{@bucket.name}/#{@key}" end end |
#reload ⇒ 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.
Force a reload of this structure from Riak.
47 48 49 50 51 52 53 54 55 |
# File 'lib/riak/crdt/base.rb', line 47 def reload loader do |l| vivify l.load @bucket, @key, @bucket_type @context = l.context end @dirty = false self end |