Method: EntityStore::Build.assure

Defined in:
lib/entity_store/entity_store.rb

.assure(instance) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/entity_store/entity_store.rb', line 73

def self.assure(instance)
  if instance.category.nil?
    raise Error, "Category is not declared"
  end

  if instance.entity_class.nil?
    raise Error, "Entity is not declared"
  end

  if instance.projection_class.nil?
    raise Error, "Projection is not declared"
  end

  if instance.reader_class.nil?
    raise Error, "Reader is not declared"
  end

  snapshot_class = instance.snapshot_class
  unless snapshot_class.nil?
    if snapshot_class.respond_to?(:assure)
      snapshot_class.assure(instance)
    else
      raise Error, "#{snapshot_class} snapshot class doesn't implement the `assure' method"
    end
  end
end