Class: Universa::ChainStore
- Inherits:
-
Object
- Object
- Universa::ChainStore
- Defined in:
- lib/universa/chain_store.rb
Overview
Work iun progress, not to use as for now.
The storage interface capable to store contracts in chains, providing search and attributes. This class is not a store itself but the base class for it, having common boilerplate and sort of interface to implement. _Under development, we might change it_
Direct Known Subclasses
Instance Method Summary collapse
-
#<<(contract) ⇒ ChainStore
Same as #store_contract but returns store.
-
#count ⇒ Object
Count contracts in the store.
-
#find_by_id(hash_id) ⇒ Contract
With the corresponding id or nil.
-
#find_by_id!(hash_id) ⇒ Contract
With the corresponding id or raise.
-
#find_by_parent(hash_id) ⇒ Array
Find all contracts with this parent id.
-
#store_contract(contract) ⇒ StoredContract
Save contract to the store.
Instance Method Details
#<<(contract) ⇒ ChainStore
Same as #store_contract but returns store
24 25 26 27 |
# File 'lib/universa/chain_store.rb', line 24 def <<(contract) store_contract(contract) self end |
#count ⇒ Object
Count contracts in the store. This operation could be slow.
36 37 38 |
# File 'lib/universa/chain_store.rb', line 36 def count raise NotImplementedError end |
#find_by_id(hash_id) ⇒ Contract
Returns with the corresponding id or nil.
31 32 33 |
# File 'lib/universa/chain_store.rb', line 31 def find_by_id(hash_id) raise NotImplementedError end |
#find_by_id!(hash_id) ⇒ Contract
Returns with the corresponding id or raise.
43 44 45 |
# File 'lib/universa/chain_store.rb', line 43 def find_by_id! hash_id find_by_id(hash_id) or raise NotFoundError end |
#find_by_parent(hash_id) ⇒ Array
Find all contracts with this parent id.
50 51 52 |
# File 'lib/universa/chain_store.rb', line 50 def find_by_parent(hash_id) raise NotImplementedError end |
#store_contract(contract) ⇒ StoredContract
Save contract to the store. When this method returns, the contract must me already stored. If the contract with such hasId is already stored, just returns it.
17 18 19 |
# File 'lib/universa/chain_store.rb', line 17 def store_contract(contract) raise NotImplementedError end |