Class: Bio::NeXML::Mapper::HashRepository
- Inherits:
-
Hash
- Object
- Hash
- Bio::NeXML::Mapper::HashRepository
- Defined in:
- lib/bio/db/nexml/mapper/repository.rb
Overview
Repository is a hash based store for NeXML objects.
Instance Method Summary collapse
-
#<<(object) ⇒ Object
(also: #append)
Append a method to the Repository.
- #__delete__ ⇒ Object
- #__each__ ⇒ Object
-
#delete(object) ⇒ Object
Delete an object.
-
#each(&block) ⇒ Object
Iterate over each object in the repository.
-
#each_with_id(&block) ⇒ Object
Iterate over each object passing both the id and the object to the block given.
- #include?(object) ⇒ Boolean
- #objects ⇒ Object
-
#objects=(objects) ⇒ Object
Reset the object in the repository to use the ones passed.
Instance Method Details
#<<(object) ⇒ Object Also known as: append
Append a method to the Repository.
9 10 11 12 |
# File 'lib/bio/db/nexml/mapper/repository.rb', line 9 def <<( object ) self[ object.id ] = object self end |
#__delete__ ⇒ Object
25 |
# File 'lib/bio/db/nexml/mapper/repository.rb', line 25 alias __delete__ delete |
#__each__ ⇒ Object
32 |
# File 'lib/bio/db/nexml/mapper/repository.rb', line 32 alias __each__ each |
#delete(object) ⇒ Object
Delete an object.
28 29 30 |
# File 'lib/bio/db/nexml/mapper/repository.rb', line 28 def delete( object ) __delete__( object.id ) end |
#each(&block) ⇒ Object
Iterate over each object in the repository.
35 36 37 |
# File 'lib/bio/db/nexml/mapper/repository.rb', line 35 def each( &block ) each_value( &block ) end |
#each_with_id(&block) ⇒ Object
Iterate over each object passing both the id and the object to the block given.
41 42 43 |
# File 'lib/bio/db/nexml/mapper/repository.rb', line 41 def each_with_id( &block ) __each__( &block ) end |
#include?(object) ⇒ Boolean
45 46 47 |
# File 'lib/bio/db/nexml/mapper/repository.rb', line 45 def include?( object ) self[ object.id ] == object end |
#objects ⇒ Object
21 22 23 |
# File 'lib/bio/db/nexml/mapper/repository.rb', line 21 def objects self.values end |
#objects=(objects) ⇒ Object
Reset the object in the repository to use the ones passed.
16 17 18 19 |
# File 'lib/bio/db/nexml/mapper/repository.rb', line 16 def objects=( objects ) self.clear objects.each { |o| self << o } end |