Class: Bio::NeXML::Mapper::HashRepository

Inherits:
Hash
  • Object
show all
Defined in:
lib/bio/db/nexml/mapper/repository.rb

Overview

Repository is a hash based store for NeXML objects.

Instance Method Summary collapse

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

Returns:

  • (Boolean)


45
46
47
# File 'lib/bio/db/nexml/mapper/repository.rb', line 45

def include?( object )
  self[ object.id ] == object
end

#objectsObject



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