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.
- #graph ⇒ RDF::Graph
- #graph=(graph) ⇒ RDF::Graph
-
#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 |
# File 'lib/active_triples/persistence_strategies/persistence_strategy.rb', line 25 def destroy(&block) yield if block_given? persist! @destroyed = true end |
#destroyed? ⇒ true, false
Indicates if the Resource has been destroyed.
37 38 39 |
# File 'lib/active_triples/persistence_strategies/persistence_strategy.rb', line 37 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.
79 80 81 82 |
# File 'lib/active_triples/persistence_strategies/persistence_strategy.rb', line 79 def erase_old_resource raise NotImplementedError, 'Abstract method #erase_old_resource is unimplemented' end |
#graph ⇒ RDF::Graph
69 70 71 |
# File 'lib/active_triples/persistence_strategies/persistence_strategy.rb', line 69 def graph @graph ||= RDF::Graph.new end |
#graph=(graph) ⇒ RDF::Graph
63 64 65 |
# File 'lib/active_triples/persistence_strategies/persistence_strategy.rb', line 63 def graph=(graph) @graph = graph 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.
56 57 58 |
# File 'lib/active_triples/persistence_strategies/persistence_strategy.rb', line 56 def persist! raise NotImplementedError, 'Abstract method #persist! is unimplemented' end |
#persisted? ⇒ Boolean
Indicates if the resource is persisted to the datastore / repository
45 46 47 |
# File 'lib/active_triples/persistence_strategies/persistence_strategy.rb', line 45 def persisted? @persisted ||= false end |
#reload ⇒ Boolean
Repopulate the in-memory graph from the persisted graph
88 89 90 |
# File 'lib/active_triples/persistence_strategies/persistence_strategy.rb', line 88 def reload raise NotImplementedError, 'Abstract method #reload is unimplemented' end |