Class: Google::Cloud::Firestore::Query
- Inherits:
-
Object
- Object
- Google::Cloud::Firestore::Query
show all
- Includes:
- Enumerable
- Defined in:
- lib/act_as_fire_record_beta/google/cloud/firestore/query.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/act_as_fire_record_beta/google/cloud/firestore/query.rb', line 7
def method_missing(sym, *args)
if respond_to_missing?(sym, false)
self.to_a.send(sym, *args)
else
super
end
end
|
Instance Method Details
#destroy_all ⇒ Object
37
38
39
40
|
# File 'lib/act_as_fire_record_beta/google/cloud/firestore/query.rb', line 37
def destroy_all
doc_refs = self.map(&:doc_ref)
fire_record_class.delete_in_batch(doc_refs)
end
|
#each(&b) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/act_as_fire_record_beta/google/cloud/firestore/query.rb', line 19
def each(&b)
records = get.map do |data|
record = fire_record_class.to_instance(data)
b.call(record) if b
record
end
b ? records : records.each
end
|
#exists? ⇒ Boolean
47
48
49
|
# File 'lib/act_as_fire_record_beta/google/cloud/firestore/query.rb', line 47
def exists?
!!first
end
|
#fire_record_class ⇒ Object
51
52
53
|
# File 'lib/act_as_fire_record_beta/google/cloud/firestore/query.rb', line 51
def fire_record_class
@_fire_record_class ||= ActAsFireRecordBeta.class_mapping[query.from[0].collection_id]
end
|
#first(limit = 1) ⇒ Object
42
43
44
45
|
# File 'lib/act_as_fire_record_beta/google/cloud/firestore/query.rb', line 42
def first(limit = 1)
records = limit(limit)
limit == 1 ? records[0] : records
end
|
#inspect ⇒ Object
28
29
30
31
|
# File 'lib/act_as_fire_record_beta/google/cloud/firestore/query.rb', line 28
def inspect
entries = self.to_a.map(&:inspect)
"#<#{self.class.name} [#{entries.join(', ')}]>"
end
|
#pretty_print(q) ⇒ Object
33
34
35
|
# File 'lib/act_as_fire_record_beta/google/cloud/firestore/query.rb', line 33
def pretty_print(q)
q.pp(self.to_a)
end
|
#respond_to_missing?(sym, _include_private) ⇒ Boolean
15
16
17
|
# File 'lib/act_as_fire_record_beta/google/cloud/firestore/query.rb', line 15
def respond_to_missing?(sym, _include_private)
[].respond_to?(sym) ? true : super
end
|