Module: Persistence::Adapter::Mock::Bucket::Index::IndexInterface
- Included in:
- Persistence::Adapter::Mock::Bucket::Index
- Defined in:
- lib/persistence/adapter/mock/bucket/index/index_interface.rb
Overview
Interface implementation for Index class instances.
Instance Attribute Summary collapse
-
#parent_bucket ⇒ Persistence::Adapter::Mock::Bucket
Track parent bucket for this index.
Instance Method Summary collapse
-
#count ⇒ Integer
Get the number of indexed objects in this index.
-
#cursor ⇒ Persistence::Adapter::Mock::Cursor
Create and return cursor instance for this index.
-
#delete_keys_for_object_id!(global_id) ⇒ Object
Delete all keys in this index for object ID.
-
#get_object_id(key) ⇒ Object
Retrieve indexed object ID for index key.
-
#index_object_id(global_id, key) ⇒ Object
Index object ID for index key.
- #initialize(index_name, parent_bucket, permits_duplicates) ⇒ Object
-
#permits_duplicates? ⇒ true, false
Reports whether this index permits duplicate indexed entries per key.
Instance Attribute Details
#parent_bucket ⇒ Persistence::Adapter::Mock::Bucket
Track parent bucket for this index.
39 40 41 |
# File 'lib/persistence/adapter/mock/bucket/index/index_interface.rb', line 39 def parent_bucket @parent_bucket end |
Instance Method Details
#count ⇒ Integer
Get the number of indexed objects in this index.
65 66 67 68 69 |
# File 'lib/persistence/adapter/mock/bucket/index/index_interface.rb', line 65 def count return @keys.count end |
#cursor ⇒ Persistence::Adapter::Mock::Cursor
Create and return cursor instance for this index.
50 51 52 53 54 |
# File 'lib/persistence/adapter/mock/bucket/index/index_interface.rb', line 50 def cursor return ::Persistence::Adapter::Mock::Cursor.new( @parent_bucket, self ) end |
#delete_keys_for_object_id!(global_id) ⇒ Object
Delete all keys in this index for object ID.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/persistence/adapter/mock/bucket/index/index_interface.rb', line 135 def delete_keys_for_object_id!( global_id ) index_value_or_keys = @reverse_keys.delete( global_id ) if index_value_or_keys.is_a?( ::Array ) index_value_or_keys.each do |this_key| @keys.delete( this_key ) end else @keys.delete( index_value_or_keys ) end return self end |
#get_object_id(key) ⇒ Object
Retrieve indexed object ID for index key.
118 119 120 121 122 |
# File 'lib/persistence/adapter/mock/bucket/index/index_interface.rb', line 118 def get_object_id( key ) return @keys[ key ] end |
#index_object_id(global_id, key) ⇒ Object
Index object ID for index key.
98 99 100 101 102 103 104 105 |
# File 'lib/persistence/adapter/mock/bucket/index/index_interface.rb', line 98 def index_object_id( global_id, key ) @keys[ key ] = global_id @reverse_keys[ global_id ] = key return self end |
#initialize(index_name, parent_bucket, permits_duplicates) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/persistence/adapter/mock/bucket/index/index_interface.rb', line 17 def initialize( index_name, parent_bucket, permits_duplicates ) @name = index_name @keys = { } @reverse_keys = { } @permits_duplicates = permits_duplicates @parent_bucket = parent_bucket end |
#permits_duplicates? ⇒ true, false
Reports whether this index permits duplicate indexed entries per key.
80 81 82 83 84 |
# File 'lib/persistence/adapter/mock/bucket/index/index_interface.rb', line 80 def permits_duplicates? return @permits_duplicates end |