Module: ActiveTriples::Persistable Abstract
- Extended by:
- ActiveSupport::Concern
- Includes:
- RDF::Enumerable, RDF::Mutable
- Included in:
- RDFSource
- Defined in:
- lib/active_triples/persistable.rb
Overview
implement #graph as a reference to an ‘RDF::Graph` or similar.
Bundles the core interfaces used by ActiveTriples persistence strategies to treat a graph as persistable. Specificially:
- RDF::Enumerable
- RDF::Mutable
Instance Method Summary collapse
- #delete_statement(*args) ⇒ Object
-
#destroy ⇒ Boolean
(also: #destroy!)
Removes the statements in this RDFSource’s graph from the persisted graph.
-
#destroyed? ⇒ Boolean
True if this item is destroyed.
-
#graph ⇒ RDF::Graph
This gives the RDF::Graph which represents the current state of this resource.
- #insert_statement(*args) ⇒ Object
-
#persist!(opts = {}) ⇒ Boolean
Sends a persistence message to the ‘persistence_startegy`, saving the `Persistable`.
-
#persisted? ⇒ Boolean
Indicates if the resource is persisted.
-
#persistence_strategy ⇒ Object
Returns the persistence strategy object that handles this object’s persistence.
-
#reload ⇒ Boolean
Repopulates the graph according to the persistence strategy.
-
#set_persistence_strategy(klass) ⇒ Object
Sets a persistence strategy.
Instance Method Details
#delete_statement(*args) ⇒ Object
37 38 39 |
# File 'lib/active_triples/persistable.rb', line 37 def delete_statement(*args) graph.send(:delete_statement, *args) end |
#destroy ⇒ Boolean Also known as: destroy!
Removes the statements in this RDFSource’s graph from the persisted graph
61 62 63 |
# File 'lib/active_triples/persistable.rb', line 61 def destroy persistence_strategy.destroy end |
#destroyed? ⇒ Boolean
Returns true if this item is destroyed.
68 69 70 |
# File 'lib/active_triples/persistable.rb', line 68 def destroyed? persistence_strategy.destroyed? end |
#graph ⇒ RDF::Graph
This gives the RDF::Graph which represents the current state of this resource.
26 27 28 |
# File 'lib/active_triples/persistable.rb', line 26 def graph persistence_strategy.graph end |
#insert_statement(*args) ⇒ Object
31 32 33 |
# File 'lib/active_triples/persistable.rb', line 31 def insert_statement(*args) graph.send(:insert_statement, *args) end |
#persist!(opts = {}) ⇒ Boolean
Sends a persistence message to the ‘persistence_startegy`, saving the `Persistable`.
77 78 79 80 81 82 83 84 |
# File 'lib/active_triples/persistable.rb', line 77 def persist!(opts={}) result = false return result if opts[:validate] && !valid? run_callbacks :persist do result = persistence_strategy.persist! end result end |
#persisted? ⇒ Boolean
Indicates if the resource is persisted.
91 92 93 |
# File 'lib/active_triples/persistable.rb', line 91 def persisted? persistence_strategy.persisted? end |
#persistence_strategy ⇒ Object
Returns the persistence strategy object that handles this object’s persistence
44 45 46 |
# File 'lib/active_triples/persistable.rb', line 44 def persistence_strategy @persistence_strategy || set_persistence_strategy(RepositoryStrategy) end |
#reload ⇒ Boolean
Repopulates the graph according to the persistence strategy
99 100 101 102 |
# File 'lib/active_triples/persistable.rb', line 99 def reload @term_cache ||= {} persistence_strategy.reload end |
#set_persistence_strategy(klass) ⇒ Object
Sets a persistence strategy
53 54 55 |
# File 'lib/active_triples/persistable.rb', line 53 def set_persistence_strategy(klass) @persistence_strategy = klass.new(self) end |