like_query 0.0.3 → 0.0.5
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/lib/like_query/collect.rb +14 -12
- data/lib/like_query/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 334fa972fb8d61c1e906bd9dc086e10163b7840dd10fd6a13eed59118841f04c
|
4
|
+
data.tar.gz: 0d76d9085d8e3f65cca59b3cad4abcd798106cf3792a85bf67634a776bf89ae9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbf4216ef96477617063c1a920b4754706302b6437bde18c303c16a0a2409d6bbb0d340a2674027097f89e47eea66816257f5e63995cc1017782a00b1de2c26e
|
7
|
+
data.tar.gz: cd639637a1835e3e5e67c6c94f1ceb4b01adc9ed5c7f083edd025cd690b86d2d57d754efbb932f1dea34a2ae2e28fad32f637622882138e37d4523ded05d0771
|
data/lib/like_query/collect.rb
CHANGED
@@ -15,6 +15,7 @@ module LikeQuery
|
|
15
15
|
|
16
16
|
return false if @length >= @limit
|
17
17
|
length = 0
|
18
|
+
@image = image.present?
|
18
19
|
|
19
20
|
recs = yield
|
20
21
|
|
@@ -42,12 +43,12 @@ module LikeQuery
|
|
42
43
|
|
43
44
|
if assoc.to_sym == :image
|
44
45
|
|
45
|
-
raise 'Missing input: image column for given key :image' unless cols.present?
|
46
|
-
|
47
|
-
# IMAGE COLUMN
|
48
|
-
|
49
|
-
rec_attr[:image] = get_column_value(r, cols)
|
50
|
-
@image = true
|
46
|
+
# raise 'Missing input: image column for given key :image' unless cols.present?
|
47
|
+
#
|
48
|
+
# # IMAGE COLUMN
|
49
|
+
#
|
50
|
+
# rec_attr[:image] = get_column_value(r, cols)
|
51
|
+
# @image = true
|
51
52
|
|
52
53
|
else
|
53
54
|
|
@@ -58,7 +59,7 @@ module LikeQuery
|
|
58
59
|
|
59
60
|
_cols = if cols.is_a?(Hash)
|
60
61
|
image_column = cols[:image]
|
61
|
-
cols[:
|
62
|
+
cols[:values]
|
62
63
|
elsif cols.is_a?(Enumerable)
|
63
64
|
cols
|
64
65
|
else
|
@@ -68,7 +69,7 @@ module LikeQuery
|
|
68
69
|
(sub_records.is_a?(Enumerable) ? sub_records : [sub_records]).each do |sub_record|
|
69
70
|
sub_attr = []
|
70
71
|
_cols.each do |c|
|
71
|
-
sub_attr.push(
|
72
|
+
sub_attr.push(sub_record.send(c))
|
72
73
|
end
|
73
74
|
|
74
75
|
if @length >= @limit || (limit && length >= limit)
|
@@ -79,7 +80,7 @@ module LikeQuery
|
|
79
80
|
@sub_records_columns_count = c if c > @sub_records_columns_count
|
80
81
|
rec_attr[:associations] ||= {}
|
81
82
|
rec_attr[:associations][assoc] ||= []
|
82
|
-
sub_hash = {
|
83
|
+
sub_hash = { values: sub_attr, id: sub_record.id, model: sub_record.class.to_s.underscore }
|
83
84
|
if image_column
|
84
85
|
sub_hash[:image] = get_column_value(sub_record, image_column)
|
85
86
|
@sub_records_image = true
|
@@ -95,10 +96,11 @@ module LikeQuery
|
|
95
96
|
|
96
97
|
# MAIN RECORD
|
97
98
|
|
98
|
-
rec_attr[:
|
99
|
-
rec_attr[:
|
99
|
+
rec_attr[:values] ||= []
|
100
|
+
rec_attr[:values].push(get_column_value(r, p))
|
100
101
|
rec_attr[:id] = r.id
|
101
102
|
rec_attr[:model] = r.class.to_s.underscore
|
103
|
+
rec_attr[:image] = r.send(image) if @image
|
102
104
|
|
103
105
|
end
|
104
106
|
end
|
@@ -106,7 +108,7 @@ module LikeQuery
|
|
106
108
|
@overflow = true
|
107
109
|
break
|
108
110
|
else
|
109
|
-
c = (image ? 1 : 0) + rec_attr[:
|
111
|
+
c = (image ? 1 : 0) + rec_attr[:values].length
|
110
112
|
@columns_count = c if c > @columns_count
|
111
113
|
@data.push(rec_attr)
|
112
114
|
@length += 1
|
data/lib/like_query/version.rb
CHANGED