Class: DeepStore::Repository
- Inherits:
-
Object
- Object
- DeepStore::Repository
- Extended by:
- Forwardable
- Defined in:
- lib/deep_store/repository.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#codec ⇒ Object
readonly
Returns the value of attribute codec.
-
#dao ⇒ Object
readonly
Returns the value of attribute dao.
-
#resource_class ⇒ Object
readonly
Returns the value of attribute resource_class.
Instance Method Summary collapse
- #destroy(key) ⇒ Object
- #find(key) ⇒ Object
-
#initialize(data = {}) ⇒ Repository
constructor
A new instance of Repository.
- #save(resource) ⇒ Object
- #where(query = {}) ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Repository
Returns a new instance of Repository.
10 11 12 13 14 15 16 17 |
# File 'lib/deep_store/repository.rb', line 10 def initialize(data = {}) @data = data @adapter = data.fetch(:adapter, DeepStore.adapter) @bucket = data.fetch(:bucket, DeepStore.settings.bucket) @codec = data.fetch(:codec) @resource_class = data.fetch(:resource_class) @dao = DAO.new(adapter: @adapter, bucket: @bucket, codec: @codec) end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/deep_store/repository.rb', line 5 def adapter @adapter end |
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
6 7 8 |
# File 'lib/deep_store/repository.rb', line 6 def bucket @bucket end |
#codec ⇒ Object (readonly)
Returns the value of attribute codec.
6 7 8 |
# File 'lib/deep_store/repository.rb', line 6 def codec @codec end |
#dao ⇒ Object (readonly)
Returns the value of attribute dao.
6 7 8 |
# File 'lib/deep_store/repository.rb', line 6 def dao @dao end |
#resource_class ⇒ Object (readonly)
Returns the value of attribute resource_class.
6 7 8 |
# File 'lib/deep_store/repository.rb', line 6 def resource_class @resource_class end |
Instance Method Details
#destroy(key) ⇒ Object
31 32 33 |
# File 'lib/deep_store/repository.rb', line 31 def destroy(key) Operations::DestroyOperation.new(dao, resource_class, key: key).result end |
#find(key) ⇒ Object
19 20 21 |
# File 'lib/deep_store/repository.rb', line 19 def find(key) Operations::FindQuery.new(dao, resource_class, key: key).result end |
#save(resource) ⇒ Object
27 28 29 |
# File 'lib/deep_store/repository.rb', line 27 def save(resource) Operations::SaveOperation.new(dao, resource_class, resource: resource).result end |
#where(query = {}) ⇒ Object
23 24 25 |
# File 'lib/deep_store/repository.rb', line 23 def where(query = {}) Operations::WhereQuery.new(dao, resource_class, query: query).result end |