like_query 0.0.10 → 0.0.11

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: bc4a3562c9d002c102211f00d8601395dc5aec93966b82a79d23a5f9b300d3ae
4
- data.tar.gz: 9d38c87fa3900aefb5e9a18ac9196ed547bd50452f0cc8da3228e2cb7345ab33
3
+ metadata.gz: e95c2eabf9ea159ab3f1736583e94d6da0801468dca417291bb7ed23f33d1f02
4
+ data.tar.gz: 99e33fcc32fdd5925195efeae70d43acb428ca6b7cdf30d10ed21aba89c3bbfb
5
5
  SHA512:
6
- metadata.gz: 27139acd2fb75cd01b1d7e4853ec13ed969bfa684a6303e9091aa8e5049259f61f1ad18d2f647a2a3e1a74af80b685e585f39129377146abcc616231a2a90948
7
- data.tar.gz: 0f9f0794416e3f0d4a63b75accef14b5e6efd8f716652386e7b5c8c9c4b692d140e16ccdbb8cd513abb9d2cd922c9ad036be13634b43496a41982054382045c2
6
+ metadata.gz: d0f81f09950603552f42c4ca441a5d673a4a3fe297051c20c200d99ebaa10333fad25d723967a435a30f71bb8000f5fa7befb4db239c9373ac47795a544036a9
7
+ data.tar.gz: fe6b40c8b51b5c01492f1be4498186d2d97959ddfe65ec4acede98db6d8a04b7f560d65d78651f9c2d462166a68894f71d42f954c314162824e2ec9f666531c5
@@ -18,10 +18,12 @@ module LikeQuery
18
18
  @start_time = Time.now
19
19
  @schemes = {}
20
20
  @images = {}
21
+ @urls = {}
21
22
  end
22
23
 
23
- def set_schema(model, schema)
24
+ def set_schema(model, schema = nil, url: nil)
24
25
  @schemes[model.to_s] = schema_to_hash(schema)
26
+ @urls[model.to_s] = url if url
25
27
  end
26
28
 
27
29
  def collect(output_schema = nil, limit: nil, parent: nil, image: nil, url: nil, &block)
@@ -38,6 +40,7 @@ module LikeQuery
38
40
  end
39
41
  model_name = recs.klass.to_s
40
42
  schema = @schemes[model_name] || schema_to_hash(nil)
43
+ _url = url || @urls[model_name]
41
44
  _img = image || schema[:image]
42
45
  if _img.present?
43
46
  @images[model_name] = _img
@@ -60,7 +63,7 @@ module LikeQuery
60
63
 
61
64
  if parent
62
65
  parent_record = rec.send(parent)
63
- r = record_to_hash(rec, schema, image, parent_record, url: url)
66
+ r = record_to_hash(rec, schema, image, parent_record, url: _url)
64
67
  parent_class_name = parent_record.class.to_s
65
68
  parent_key = "#{parent_class_name}#{parent_record.id}"
66
69
 
@@ -70,13 +73,13 @@ module LikeQuery
70
73
  Rails.logger.debug("WARNING: NO SCHEMA GIVEN FOR «#{parent_class_name}»")
71
74
  parent_schema = schema_to_hash(nil)
72
75
  end
73
- @data[parent_key] = record_to_hash(parent_record, parent_schema, @images[parent_class_name])
76
+ @data[parent_key] = record_to_hash(parent_record, parent_schema, @images[parent_class_name], url: @urls[parent_class_name])
74
77
  @length += 1
75
78
  end
76
79
  @data[parent_key][:children] ||= []
77
80
  @data[parent_key][:children].push(r)
78
81
  else
79
- r = record_to_hash(rec, schema, image, url: url)
82
+ r = record_to_hash(rec, schema, image, url: _url)
80
83
  @data["#{rec.class}#{rec.id}"] = r
81
84
  end
82
85
  c = (@image ? 1 : 0) + r[:values].to_a.length
@@ -1,3 +1,3 @@
1
1
  module LikeQuery
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
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.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian