Module: ActiveTriples::PersistenceStrategy Abstract
- Included in:
- ParentStrategy, RepositoryStrategy
- Defined in:
- lib/active_triples/persistence_strategies/persistence_strategy.rb
Overview
defines the basic interface for persistence of RDFSource‘s.
A ‘PersistenceStrategy` has an underlying resource which should be an `RDFSource` or equivalent. Strategies can be injected into `RDFSource` instances at runtime to change the target datastore, repository, or object the instance syncs its graph with on save and reload operations.
Instance Method Summary collapse
-
#destroy { ... } ⇒ Boolean
(also: #destroy!)
Deletes the resource from the datastore / repository.
-
#destroyed? ⇒ true, false
Indicates if the Resource has been destroyed.
-
#erase_old_resource ⇒ Boolean
abstract
about this node or statement thus preparing to receive the updated assertions.
-
#persist! ⇒ true
abstract
True if the save did not error.
-
#persisted? ⇒ Boolean
Indicates if the resource is persisted to the datastore / repository.
- #reload ⇒ Boolean abstract
Instance Method Details
#destroy { ... } ⇒ Boolean Also known as: destroy!
Deletes the resource from the datastore / repository.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/active_triples/persistence_strategies/persistence_strategy.rb', line 25 def destroy(&block) yield if block_given? # Provide a warning for strategies relying on #destroy to clear the resource if defined? obj warn "DEPRECATION WARNING: #destroy implementations must now explicitly call 'source.clear'" obj.clear end persist! @destroyed = true end |
#destroyed? ⇒ true, false
Indicates if the Resource has been destroyed.
43 44 45 |
# File 'lib/active_triples/persistence_strategies/persistence_strategy.rb', line 43 def destroyed? @destroyed ||= false end |
#erase_old_resource ⇒ Boolean
Clear out any old assertions in the datastore / repository
about this node or statement thus preparing to receive the updated assertions.
72 73 74 75 |
# File 'lib/active_triples/persistence_strategies/persistence_strategy.rb', line 72 def erase_old_resource raise NotImplementedError, 'Abstract method #erase_old_resource is unimplemented' end |
#persist! ⇒ true
save the resource according to the strategy and set the @persisted flag to ‘true`
Returns true if the save did not error.
62 63 64 |
# File 'lib/active_triples/persistence_strategies/persistence_strategy.rb', line 62 def persist! raise NotImplementedError, 'Abstract method #persist! is unimplemented' end |
#persisted? ⇒ Boolean
Indicates if the resource is persisted to the datastore / repository
51 52 53 |
# File 'lib/active_triples/persistence_strategies/persistence_strategy.rb', line 51 def persisted? @persisted ||= false end |
#reload ⇒ Boolean
Repopulate the in-memory graph from the persisted graph
81 82 83 |
# File 'lib/active_triples/persistence_strategies/persistence_strategy.rb', line 81 def reload raise NotImplementedError, 'Abstract method #reload is unimplemented' end |