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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af0d8c5d6b6d9c34b27abe4e2d6c9e6a56332a34
4
- data.tar.gz: 61709857c463321cfa11b987d01420c1d1cf2a43
3
+ metadata.gz: 18df48b295e105e1121f6fc319414d4d275396aa
4
+ data.tar.gz: 14468ba5dfa2eaf884e270cc4835483d4572f6e1
5
5
  SHA512:
6
- metadata.gz: 28fbf425d5d62dfd31966a701a7bbb093aec2f27bde60c6f3b73b5349ab26593adb54d1797db5a5fb8e37fea0d0987f94230f703a7f5ed99ef999ccb9970153a
7
- data.tar.gz: 009725b2871b44eb8adfca8e2ea0eee43afd8093ebd11405e81f68bcdb67ec25275dc78ecd084d4bc5bd1e45ad34bdf3e1132bbba450fcedefe77b919e4730da
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
- ```yml
18
- # config/mongo.yml
19
-
20
- development:
21
- hosts:
22
- - 'localhost:27017'
23
- params:
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Fish0
2
- VERSION = '0.0.6'.freeze
2
+ VERSION = '0.0.7'.freeze
3
3
  end
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.6
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-21 00:00:00.000000000 Z
11
+ date: 2016-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport