like_query 0.0.8 → 0.0.9

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: c46b541528f87a7bd078c47eaa7bc264503ff6b1c333af0caf18aacb2beea24c
4
- data.tar.gz: 8d5d867c0707f5cfe827a4d55082434d5e02bec45528f04737a8927746388fcd
3
+ metadata.gz: '09331b69e73a5710ea602d9f20c26a11453589480b8be7130bb678a430c13f17'
4
+ data.tar.gz: 82eb9cb8c04f0c3d0d6fa7bccd22fde4cf9468a3aec31f533f2ce8d2fb9d0765
5
5
  SHA512:
6
- metadata.gz: aaf145febd6f66ee1549dd8d2d5b5285d1c191f6e5759519ec5053eb88a6055c087411ab3d4962afb282d3c208f439f9a7fad5f852797a3466e93c22238f6aba
7
- data.tar.gz: 7097e44705ad35add8233002e3db0e0b20330525197a3dcc4d15070e43d38f03221c3f2e9902e8677ee6e273e68e6eaf4490d6bc825ce82fdce2722d0301dd2d
6
+ metadata.gz: '090626d9d0b0afe7879c6a7053e9ab3e87fd7e3faa797015ab47bbc258c41ee19bc2666fda4bb0bfacb8c563e871e9f75c2e959275836d0233955f3cd7fdbdad'
7
+ data.tar.gz: c1835c63c13d9b09d084b34b6b7ae24db6cf890317166e130e13daf56f8f8baabe6d4ae49bc9f36b94798276caa07853fbca6eee0f58978bca143dfecd7a76d1
@@ -24,7 +24,7 @@ module LikeQuery
24
24
  @schemes[model.to_s] = schema_to_hash(schema)
25
25
  end
26
26
 
27
- def collect(output_schema = nil, limit: nil, parent: nil, image: nil, &block)
27
+ def collect(output_schema = nil, limit: nil, parent: nil, image: nil, url: nil, &block)
28
28
 
29
29
  _limit = (limit ? (@limit && @limit < limit ? @limit : limit) : @limit)
30
30
  return false if @length >= _limit
@@ -76,7 +76,7 @@ module LikeQuery
76
76
  @data[parent_key][:children] ||= []
77
77
  @data[parent_key][:children].push(r)
78
78
  else
79
- r = record_to_hash(rec, schema, image)
79
+ r = record_to_hash(rec, schema, image, url: url)
80
80
  @data["#{rec.class}#{rec.id}"] = r
81
81
  end
82
82
  c = (@image ? 1 : 0) + r[:values].to_a.length
@@ -109,7 +109,7 @@ module LikeQuery
109
109
 
110
110
  private
111
111
 
112
- def record_to_hash(record, schema, image, parent = nil)
112
+ def record_to_hash(record, schema, image, parent = nil, url: nil)
113
113
  r = {}
114
114
  schema[:values].each do |k|
115
115
  v = get_column_value(record, k)
@@ -126,6 +126,7 @@ module LikeQuery
126
126
  r[:model] = record.class.to_s
127
127
  end
128
128
  r[:image] = record.send(image) if image
129
+ r[:url] = url.yield(record) if url
129
130
  r
130
131
  end
131
132
 
@@ -53,15 +53,15 @@ module LikeQuery
53
53
  end
54
54
  end
55
55
 
56
- def generate_hash(output_schema = nil, limit: 50, image: nil)
56
+ def generate_hash(output_schema = nil, limit: 50, image: nil, url: nil)
57
57
  c = LikeQuery::Collect.new(limit)
58
- c.collect(output_schema, limit: limit, image: image) { all }
58
+ c.collect(output_schema, limit: limit, image: image, url: url) { all }
59
59
  c.generate_hash
60
60
  end
61
61
 
62
- def generate_json(output_schema = nil, limit: 50, image: nil)
62
+ def generate_json(output_schema = nil, limit: 50, image: nil, url: nil)
63
63
  c = LikeQuery::Collect.new(limit)
64
- c.collect(output_schema, limit: limit, image: image) { all }
64
+ c.collect(output_schema, limit: limit, image: image, url: url) { all }
65
65
  c.generate_json
66
66
  end
67
67
 
@@ -1,3 +1,3 @@
1
1
  module LikeQuery
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: like_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-01 00:00:00.000000000 Z
11
+ date: 2023-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails