Module: Opencdd::Database::Persistence

Included in:
Opencdd::Database
Defined in:
lib/opencdd/database/persistence.rb

Overview

YAML persistence: whole-database YAML (to_yaml via Model::YamlDatabase) and per-entity directory persistence (save_to_directory via Model::EntityStore). Class-method counterparts (from_yaml, load_from_directory) are defined on Database directly in database.rb.

Instance Method Summary collapse

Instance Method Details

#save_to_directory(path) ⇒ Object



15
16
17
18
# File 'lib/opencdd/database/persistence.rb', line 15

def save_to_directory(path)
  Opencdd::Model::EntityStore.new(path).save_database(self)
  self
end

#semantically_equal?(other) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
# File 'lib/opencdd/database/persistence.rb', line 20

def semantically_equal?(other)
  return false unless other.is_a?(Opencdd::Database)
  return false unless entities.size == other.entities.size
  entities.all? do |e|
    oe = other.find(e.irdi)
    oe && e.type == oe.type && e.properties == oe.properties
  end
end

#to_yaml(*args) ⇒ Object



11
12
13
# File 'lib/opencdd/database/persistence.rb', line 11

def to_yaml(*args)
  Opencdd::Model::YamlDatabase.from_database(self).to_yaml(*args)
end