Module: Persistence::Object::Index::ExplicitIndex::ExplicitIndexInterface
- Includes:
- Persistence::Object::Index
- Included in:
- Persistence::Object::Index::ExplicitIndex
- Defined in:
- lib/persistence/object/index/explicit_index/explicit_index_interface.rb
Overview
Interface for explicit index instances, which index keys that are explicitly provided.
Instance Attribute Summary
Attributes included from Persistence::Object::Index
Instance Method Summary collapse
-
#index_existing_objects ⇒ Object
We undefine :index_existing_objects because it makes no sense on an index requiring explicit keys.
-
#index_object(object, *keys) ⇒ Object
Index keys for object instance.
Methods included from Persistence::Object::Index
#adapter_index, #atomic_cursor, #count, #cursor, #delete_keys_for_object!, #delete_keys_for_object_id!, #disable, #each, #get_object_id, #index_object_id, #init_sorting_procs, #initialize, #initialize_for_bucket, #name, #permits_duplicates?, #persisted?, #sorting_proc_for_sort_name
Instance Method Details
#index_existing_objects ⇒ Object
We undefine :index_existing_objects because it makes no sense on an index requiring explicit keys.
15 |
# File 'lib/persistence/object/index/explicit_index/explicit_index_interface.rb', line 15 undef_method( :index_existing_objects ) |
#index_object(object, *keys) ⇒ Object
Index keys for object instance.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/persistence/object/index/explicit_index/explicit_index_interface.rb', line 28 def index_object( object, *keys ) if keys.empty? raise ::Persistence::Exception::IndexingObjectRequiresKeys.new, 'No keys provided for index.' end # check for existing index on keys if we don't permit duplicates unless permits_duplicates? keys.each do |this_key| if global_id = adapter_index.get_object_id( this_key ) and global_id != object.persistence_id raise ::Persistence::Exception::DuplicateViolatesUniqueIndex.new, 'Attempt to create index for key ' + this_key.to_s + ' would create duplicates in unique index :' + @name.to_s + '.' end end end keys.each do |this_key| adapter_index.index_object_id( object.persistence_id, this_key ) end return self end |