class Yus::Persistence::Odba
Public Class Methods
new()
click to toggle source
# File lib/yus/persistence/odba.rb, line 13 def initialize @entities = ODBA.cache.fetch_named('entities', self) { Hash.new } end
Public Instance Methods
add_entity(entity)
click to toggle source
# File lib/yus/persistence/odba.rb, line 16 def add_entity(entity) @entities.store(Entity.sanitize(entity.name), entity) entity.odba_store @entities.odba_store entity end
delete_entity(name)
click to toggle source
# File lib/yus/persistence/odba.rb, line 22 def delete_entity(name) if entity = @entities.delete(Entity.sanitize(name)) @entities.odba_store affiliations = entity.affiliations affiliations.odba_delete unless affiliations.odba_unsaved? entity.odba_delete entity end end
entities()
click to toggle source
# File lib/yus/persistence/odba.rb, line 31 def entities @entities.values end
find_entity(name)
click to toggle source
# File lib/yus/persistence/odba.rb, line 34 def find_entity(name) @entities[Entity.sanitize(name)] end
save_entity(entity)
click to toggle source
# File lib/yus/persistence/odba.rb, line 37 def save_entity(entity) if(@entities[entity.name]) entity.odba_store else @entities.delete_if { |name, ent| ent.name == entity.name } add_entity(entity) end end