fish0 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -14
- data/lib/fish0/repository.rb +8 -4
- data/lib/fish0/version.rb +1 -1
- data/lib/fish0.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18df48b295e105e1121f6fc319414d4d275396aa
|
4
|
+
data.tar.gz: 14468ba5dfa2eaf884e270cc4835483d4572f6e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfb4c351373d39747a2e29fa6e6bd1450c93a877f4837854fef6063d00133a203520759549268a3ec8bf7386afcc61ebd39dca99f2a41914c756f99fceb2f076
|
7
|
+
data.tar.gz: f04c09c70ecfb097c3334f2a7448de08b6c7c03ce638e4c2a30cd8b75ca81142a3d2b83e223ead9400837472683b8d4a84c7adbe856b3fc01325a6ec22eb3d11
|
data/README.md
CHANGED
@@ -14,20 +14,13 @@ gem 'fish0'
|
|
14
14
|
|
15
15
|
## Configuration
|
16
16
|
|
17
|
-
```
|
18
|
-
# config/
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
:database: project_development
|
25
|
-
|
26
|
-
production:
|
27
|
-
hosts:
|
28
|
-
- 'db.project.tld:27017'
|
29
|
-
params:
|
30
|
-
:database: project_production
|
17
|
+
```ruby
|
18
|
+
# config/initializers/fish0.rb
|
19
|
+
|
20
|
+
Fish0::Configuration.configure do |config|
|
21
|
+
config.mongo_hosts = ['127.0.0.1:27017', '127.0.0.2:27017']
|
22
|
+
config.mongo_params = { database: 'project_db', read: { mode: :secondary } }
|
23
|
+
end
|
31
24
|
```
|
32
25
|
|
33
26
|
## Models
|
data/lib/fish0/repository.rb
CHANGED
@@ -10,14 +10,14 @@ module Fish0
|
|
10
10
|
|
11
11
|
include Enumerable
|
12
12
|
|
13
|
-
delegate :find, to: :source
|
13
|
+
delegate :find, :aggregate, to: :source
|
14
14
|
delegate :each, to: :all
|
15
15
|
|
16
16
|
def initialize(collection, entity_class = nil)
|
17
17
|
raise ArgumentError, 'you should provide collection name' unless collection
|
18
18
|
@collection = collection
|
19
19
|
@source = Fish0.mongo_reader[collection]
|
20
|
-
@conditions =
|
20
|
+
@conditions = default_conditions
|
21
21
|
@order = {}
|
22
22
|
@limit_quantity = 0
|
23
23
|
@skip_quantity = 0
|
@@ -76,8 +76,6 @@ module Fish0
|
|
76
76
|
self
|
77
77
|
end
|
78
78
|
|
79
|
-
protected
|
80
|
-
|
81
79
|
def fetch
|
82
80
|
scoped = find(conditions, sort: order)
|
83
81
|
scoped = scoped.projection(@projection) if @projection
|
@@ -86,6 +84,12 @@ module Fish0
|
|
86
84
|
scoped
|
87
85
|
end
|
88
86
|
|
87
|
+
protected
|
88
|
+
|
89
|
+
def default_conditions
|
90
|
+
{}
|
91
|
+
end
|
92
|
+
|
89
93
|
def to_entity
|
90
94
|
-> (attrs) { entity_class.new(attrs) }
|
91
95
|
end
|
data/lib/fish0/version.rb
CHANGED
data/lib/fish0.rb
CHANGED
@@ -17,7 +17,7 @@ module Fish0
|
|
17
17
|
class << self
|
18
18
|
def mongo_reader
|
19
19
|
Mongo::Logger.logger = mongo_config['logger'] || Rails.logger
|
20
|
-
Mongo::Client.new(mongo_config[:hosts], mongo_config[:params])
|
20
|
+
@mongo_reader ||= Mongo::Client.new(mongo_config[:hosts], mongo_config[:params])
|
21
21
|
end
|
22
22
|
|
23
23
|
def mongo_config
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fish0
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Zuev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|