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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb533ef11731913bdf3356f5177354cbdc85b4506ba2aae392f7149b7fe7e6d2
4
- data.tar.gz: 4b256fb9aa9336559e6a9fc529e7376fae1f6fc09da1cd9b662eb18dd770c5dd
3
+ metadata.gz: 334fa972fb8d61c1e906bd9dc086e10163b7840dd10fd6a13eed59118841f04c
4
+ data.tar.gz: 0d76d9085d8e3f65cca59b3cad4abcd798106cf3792a85bf67634a776bf89ae9
5
5
  SHA512:
6
- metadata.gz: 6fdeaadc79ef10c0690dff7d0213d8241ea0f01679fdb1494d95bb4b9f975813ef5319ae2639a431bb291793ca74ceb1902ca11e9ba5ad9b7423f114c4b3ed0e
7
- data.tar.gz: 7d53223f4fe56b448e28aebb46e3db3f400de45b7698a5a3526543612180f4a937951733ade9cff093e177e9d4340fd50b90cc132ea64be811cde32ab2440e7b
6
+ metadata.gz: cbf4216ef96477617063c1a920b4754706302b6437bde18c303c16a0a2409d6bbb0d340a2674027097f89e47eea66816257f5e63995cc1017782a00b1de2c26e
7
+ data.tar.gz: cd639637a1835e3e5e67c6c94f1ceb4b01adc9ed5c7f083edd025cd690b86d2d57d754efbb932f1dea34a2ae2e28fad32f637622882138e37d4523ded05d0771
@@ -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[:attributes]
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([c, sub_record.send(c)])
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 = { attributes: sub_attr, id: sub_record.id, model: sub_record.class.to_s.underscore }
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[:attributes] ||= []
99
- rec_attr[:attributes].push([p, get_column_value(r, p)])
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[:attributes].length
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
@@ -1,3 +1,3 @@
1
1
  module LikeQuery
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: like_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian