module EntityStore::Build
Public Class Methods
assure(instance)
click to toggle source
# File lib/entity_store/entity_store.rb, line 78 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
Public Instance Methods
build(category: nil, specifier: nil, snapshot_interval: nil, session: nil)
click to toggle source
# File lib/entity_store/entity_store.rb, line 49 def build(category: nil, specifier: nil, snapshot_interval: nil, session: nil) instance = new instance.category = category instance.session = session instance.configure Build.assure(instance) instance.specifier = specifier unless specifier.nil? specifier ||= instance.specifier instance.snapshot_interval = snapshot_interval unless snapshot_interval.nil? snapshot_interval ||= instance.snapshot_interval EntityCache.configure( instance, entity_class, specifier, persist_interval: snapshot_interval, external_store: instance.snapshot_class, external_store_session: session, attr_name: :cache ) instance end