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
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
47 48 49 50 51 52 53 54 |
# File 'lib/riak/crdt/base.rb', line 47 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.
25 26 27 |
# File 'lib/riak/crdt/base.rb', line 25 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.
26 27 28 |
# File 'lib/riak/crdt/base.rb', line 26 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.
30 31 32 |
# File 'lib/riak/crdt/base.rb', line 30 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.
78 79 80 81 82 83 84 |
# File 'lib/riak/crdt/base.rb', line 78 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?
74 75 76 |
# File 'lib/riak/crdt/base.rb', line 74 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.
56 57 58 |
# File 'lib/riak/crdt/base.rb', line 56 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.
106 107 108 109 |
# File 'lib/riak/crdt/base.rb', line 106 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.
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/riak/crdt/base.rb', line 86 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.
99 100 101 102 103 104 |
# File 'lib/riak/crdt/base.rb', line 99 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.
61 62 63 64 65 66 67 68 69 |
# File 'lib/riak/crdt/base.rb', line 61 def reload loader do |l| vivify l.load @bucket, @key, @bucket_type @context = l.context end @dirty = false self end |