Module: Hold::SetRepository

Included in:
IdentitySetRepository, InMemory::SetRepository
Defined in:
lib/hold/interfaces/set_repository.rb

Instance Method Summary collapse

Instance Method Details

#can_get_class?(klass) ⇒ Boolean



34
# File 'lib/hold/interfaces/set_repository.rb', line 34

def can_get_class?(klass); true; end

#can_set_class?(klass) ⇒ Boolean



35
# File 'lib/hold/interfaces/set_repository.rb', line 35

def can_set_class?(klass); true; end

#contains?(object) ⇒ Boolean

Is this object in the persisted set?



25
26
27
# File 'lib/hold/interfaces/set_repository.rb', line 25

def contains?(object)
  raise UnsupportedOperation
end

#delete(object) ⇒ Object

Removes the object with this identity from the persisted set



20
21
22
# File 'lib/hold/interfaces/set_repository.rb', line 20

def delete(object)
  raise UnsupportedOperation
end

#get_allObject

Returns an array of all persisted items in the set



30
31
32
# File 'lib/hold/interfaces/set_repository.rb', line 30

def get_all
  raise UnsupportedOperation
end

#store(object) ⇒ Object

Store the object in the persisted set. If the object is already in the set, it may stay there untouched (in the case where the object’s identity is based on its entire contents), or get replaced by the newer version (where the object’s identity is only based on, say, some identity property), but will never be duplicated (since this is a set)



8
9
10
# File 'lib/hold/interfaces/set_repository.rb', line 8

def store(object)
  raise UnsupportedOperation
end

#store_new(object) ⇒ Object

like store, but should raise IdentityConflict if the object (or one equal to it) already exists in the set

Raises:



14
15
16
17
# File 'lib/hold/interfaces/set_repository.rb', line 14

def store_new(object)
  raise IdentityConflict if contains?(object)
  store(object)
end