act_as_fire_record_beta 0.0.1 → 0.0.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fa5ffce208135ba537f2eba3ae37caf239e6b49446f2d31c77668263ec178c3
|
4
|
+
data.tar.gz: c4705cc8018288e15a766bd7efde203fdb03d701db208a66cbb46409732b1077
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 382202705f5383d954bfd336137b6d74e0bf66879a3a07e8a480e4ec3e1d9427bd35e5d23180a929c39c74ab8d7d2607eff70802a8f8c86f6825a7c6e3fedcfc
|
7
|
+
data.tar.gz: '01158cd356bae1b962f62ba6575d52fb9e5648d83dc501ab8e3d0aaf2c19bffe6a5f1501aa17206a3f6f8f71a3f841370b5f7295aa8c19a07faecc249de319ab'
|
@@ -2,36 +2,26 @@ module Google
|
|
2
2
|
module Cloud
|
3
3
|
module Firestore
|
4
4
|
class Query
|
5
|
-
def
|
6
|
-
find_many(limit: 1, &block)[0]
|
7
|
-
end
|
8
|
-
|
9
|
-
def find_one!(&block)
|
10
|
-
find_one(&block) || raise(ActiveRecord::RecordNotFound)
|
11
|
-
end
|
12
|
-
|
13
|
-
def find_many(limit: nil, &block)
|
5
|
+
def get_records(limit: nil)
|
14
6
|
scope = limit ? limit(limit) : self
|
15
7
|
scope.get.map do |data|
|
16
8
|
model_lass = ActAsFireRecordBeta.class_mapping[query.from[0].collection_id]
|
17
|
-
|
18
|
-
block.call(record) if block
|
19
|
-
record
|
9
|
+
model_lass.to_instance(data)
|
20
10
|
end
|
21
11
|
end
|
22
12
|
|
23
13
|
def destroy_all
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
def exists?
|
28
|
-
!!find_one
|
14
|
+
get_records.each(&:destroy)
|
29
15
|
end
|
30
16
|
|
31
17
|
def first(limit = 1)
|
32
|
-
records =
|
18
|
+
records = get_records(limit: limit)
|
33
19
|
limit == 1 ? records[0] : records
|
34
20
|
end
|
21
|
+
|
22
|
+
def exists?
|
23
|
+
!!first
|
24
|
+
end
|
35
25
|
end
|
36
26
|
end
|
37
27
|
end
|
@@ -43,8 +43,8 @@ module ActAsFireRecordBeta
|
|
43
43
|
client.doc("#{collection_name_with_env}/#{id}")
|
44
44
|
end
|
45
45
|
|
46
|
-
def all
|
47
|
-
col.
|
46
|
+
def all
|
47
|
+
col.get_records
|
48
48
|
end
|
49
49
|
|
50
50
|
def find(id)
|
@@ -55,14 +55,14 @@ module ActAsFireRecordBeta
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def find_by(param)
|
58
|
-
raise ArgumentError, "param size should 1: #{param}" unless param.size == 1
|
58
|
+
raise ArgumentError, "param size should be 1: #{param}" unless param.size == 1
|
59
59
|
field, value = param.to_a.flatten
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
end
|
61
|
+
where(field, :==, value).first
|
62
|
+
end
|
64
63
|
|
65
|
-
|
64
|
+
def find_by!(param)
|
65
|
+
find_by(param) || raise(ActiveRecord::RecordNotFound)
|
66
66
|
end
|
67
67
|
|
68
68
|
def where(field, operator, value)
|
@@ -74,7 +74,7 @@ module ActAsFireRecordBeta
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def first(limit = 1)
|
77
|
-
records = col.
|
77
|
+
records = col.get_records(limit: limit)
|
78
78
|
limit == 1 ? records[0] : records
|
79
79
|
end
|
80
80
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: act_as_fire_record_beta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Junichi Ito
|
@@ -69,7 +69,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
69
|
requirements:
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
72
|
+
version: 3.0.0
|
73
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
75
|
- - ">="
|