Module: EntityStore::Build
- Defined in:
- lib/entity_store/entity_store.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
permalink .assure(instance) ⇒ Object
[View source]
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 |
Instance Method Details
permalink #build(category: nil, specifier: nil, snapshot_interval: nil, session: nil) ⇒ Object
[View source]
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# 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) specifier ||= instance.specifier EntityCache.configure( instance, entity_class, specifier, persist_interval: instance.snapshot_interval, external_store: instance.snapshot_class, external_store_session: session, attr_name: :cache ) instance end |