realm-rom 0.7.4 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 443eba2e7ede9e2162eb8cbaa4324c6db29ba1bee69426a1e053629451957e94
4
- data.tar.gz: 91c1ab5cf3f6b79f5205a25df6626b9c9164e4127569d984b66136887e564835
3
+ metadata.gz: 4bbd13a93d708255528c5eb107619997d0a13b9a937b1c1529d22b14bc4b34e4
4
+ data.tar.gz: 5cd03d141b3d68feb3b8eadd81b43d80f103814835d3cc0d3aad28e6282bcdb4
5
5
  SHA512:
6
- metadata.gz: b6f8acb1cce4429e5e9b386aae5259bce4108ad001225004b88125c9bfaf3089bd89b4b494af7eaa40a2f988b2821d79e1252758898342e7312a6453c27610f9
7
- data.tar.gz: 25920069362c88a229b32f555deadf380bbfc90df38cba030b3b20239329f39109437a0ff477ce8bebc1170a23593b0c736b73e238806381153d0bdbeb24c7ab
6
+ metadata.gz: f9043d3d7debe87e938dcc7a5bbf374f407a349d70f23db5b1d295843917a8d5e1a3abd1f464a853e50ae7340b98be03a97494f2a339fe2369d604fa24b01fca
7
+ data.tar.gz: 96d3764b58af1ba4a3a0e10da4f6c33b792eba650d668d5d97093e9429e67259da5da83c62258528a4249d188096a8d0b8ac3fc99b2d6dc9f6a8159418c95a2f
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Realm
4
+ module ROM
5
+ module DefaultRepositoryQueries
6
+ def find(id = nil, **conditions)
7
+ root.where({ id: id, **conditions }.compact).one!
8
+ end
9
+
10
+ def first(conditions = {})
11
+ root.where(conditions).first
12
+ end
13
+
14
+ def last(conditions = {})
15
+ root.where(conditions).last
16
+ end
17
+
18
+ def all(conditions = {})
19
+ root.where(conditions).to_a
20
+ end
21
+ end
22
+ end
23
+ end
@@ -23,14 +23,21 @@ module Realm
23
23
  end
24
24
  end
25
25
 
26
- def self.new(*)
27
- Isolated.new(super)
28
- end
26
+ class << self
27
+ def new(*)
28
+ Isolated.new(super)
29
+ end
30
+
31
+ def repo_name(value = :not_provided)
32
+ @repo_name = value.to_sym unless value == :not_provided
33
+ @repo_name ||= name.demodulize.underscore
34
+ end
35
+
36
+ def queries(type)
37
+ raise 'Only default queries are supported for now' unless type == :default
29
38
 
30
- def self.repo_name(value = :not_provided)
31
- @repo_name = value.to_sym unless value == :not_provided
32
- @repo_name = name.demodulize.underscore unless defined?(@repo_name)
33
- @repo_name
39
+ include DefaultRepositoryQueries
40
+ end
34
41
  end
35
42
 
36
43
  def readonly
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: realm-rom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - developers@reevoo.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-12 00:00:00.000000000 Z
11
+ date: 2021-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: realm-core
@@ -157,6 +157,7 @@ extensions: []
157
157
  extra_rdoc_files: []
158
158
  files:
159
159
  - lib/realm-rom.rb
160
+ - lib/realm/rom/default_repository_queries.rb
160
161
  - lib/realm/rom/gateway.rb
161
162
  - lib/realm/rom/plugin.rb
162
163
  - lib/realm/rom/rake_tasks.rb