Sha256: cb254708941f6110cc7aa2a31ceab636358ccfc61b9f28b18b8bb315edbc2a2e
Contents?: true
Size: 814 Bytes
Versions: 1
Compression:
Stored size: 814 Bytes
Contents
module Unified class EntityMap def initialize @map = {} end def set(type, id, value) @map[type] ||= {} if @map[type][id] raise Error::EntityMapOverwriteAttempt, "Cannot set #{type} #{id} because it is already defined" end @map[type][id] = value end def get(type, id) unless @map[type] raise Error::EntityMissing, "There are no #{type} entities known" end unless v = @map[type][id] raise Error::EntityMissing, "There is no #{type} #{id} known" end v end def get_any(id) @map.each do |type, sub| if sub[id] return sub[id] end end raise Error::EntityMissing, "There is no #{id} known" end def [](type) @map[type] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongo-2.15.0.alpha | spec/runners/unified/entity_map.rb |