Class: Argumenta::Storage::DHT
- Inherits:
-
Object
- Object
- Argumenta::Storage::DHT
- Defined in:
- lib/argumenta/storage/dht.rb
Overview
A DHT data store for Argumenta objects.
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
Instance Method Summary collapse
- #add_proposition(proposition) ⇒ Object
- #get_proposition(sha1) ⇒ Object
-
#initialize(options = {}) ⇒ DHT
constructor
A new instance of DHT.
Constructor Details
#initialize(options = {}) ⇒ DHT
Returns a new instance of DHT.
9 10 11 |
# File 'lib/argumenta/storage/dht.rb', line 9 def initialize( = {}) @hash = ::DHT::Hash.new end |
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
7 8 9 |
# File 'lib/argumenta/storage/dht.rb', line 7 def hash @hash end |
Instance Method Details
#add_proposition(proposition) ⇒ Object
13 14 15 16 17 |
# File 'lib/argumenta/storage/dht.rb', line 13 def add_proposition(proposition) Argumenta::Proposition.validate proposition sha1 = proposition.sha1() @hash[sha1] = proposition.text end |
#get_proposition(sha1) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/argumenta/storage/dht.rb', line 19 def get_proposition(sha1) text = @hash[sha1] unless text raise RetrievalError, "No proposition found for '#{sha1}'." end proposition = Argumenta::Proposition.new text end |