Class: Koine::Repository::Repository
- Inherits:
-
Object
- Object
- Koine::Repository::Repository
- Defined in:
- lib/koine/repository/repository.rb,
lib/koine/repository/repository/id_aware_entity.rb
Defined Under Namespace
Modules: IdAwareEntity Classes: RecordNotFound
Instance Attribute Summary collapse
-
#entity_prototype ⇒ Object
Returns the value of attribute entity_prototype.
-
#hydrator ⇒ Object
Returns the value of attribute hydrator.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #find_all_by(criterias) ⇒ Object
- #find_one_by(criterias) ⇒ Object
- #find_one_by!(criterias) ⇒ Object
-
#initialize(storage) ⇒ Repository
constructor
A new instance of Repository.
- #remove ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(storage) ⇒ Repository
Returns a new instance of Repository.
9 10 11 |
# File 'lib/koine/repository/repository.rb', line 9 def initialize(storage) @storage = storage end |
Instance Attribute Details
#entity_prototype ⇒ Object
Returns the value of attribute entity_prototype.
6 7 8 |
# File 'lib/koine/repository/repository.rb', line 6 def entity_prototype @entity_prototype end |
#hydrator ⇒ Object
Returns the value of attribute hydrator.
6 7 8 |
# File 'lib/koine/repository/repository.rb', line 6 def hydrator @hydrator end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
7 8 9 |
# File 'lib/koine/repository/repository.rb', line 7 def storage @storage end |
Instance Method Details
#find_all_by(criterias) ⇒ Object
21 22 23 |
# File 'lib/koine/repository/repository.rb', line 21 def find_all_by(criterias) hydrate_collection(storage.find_all_by(criterias)) end |
#find_one_by(criterias) ⇒ Object
25 26 27 28 |
# File 'lib/koine/repository/repository.rb', line 25 def find_one_by(criterias) raw_data = storage.find_one_by(criterias) hydrate(raw_data, new_entity) if raw_data end |
#find_one_by!(criterias) ⇒ Object
30 31 32 |
# File 'lib/koine/repository/repository.rb', line 30 def find_one_by!(criterias) find_one_by(criterias) or raise RecordNotFound end |
#remove ⇒ Object
17 18 19 |
# File 'lib/koine/repository/repository.rb', line 17 def remove(*) raise "Method not implemented" end |
#save ⇒ Object
13 14 15 |
# File 'lib/koine/repository/repository.rb', line 13 def save(*) raise "Method not implemented" end |