arql 0.1.12 → 0.1.13
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/Gemfile.lock +1 -1
- data/lib/arql/ext/array.rb +19 -6
- data/lib/arql/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: e38b5865065ed505f7b673f61ad896ff1705334311f559d23124b9c73eae4832
|
4
|
+
data.tar.gz: bd5fc96a17c9ebd68d158da1a867e7f6f40c398caaa647bc3c2512cefa4aa311
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adce379a72d895d75ccfa1b2f29da270efb64237b3bcaec2a016d163631dcc09e674e2cb88920a44d53eb80551742b6a68d5385dbd8c7e2b43ddaa8bdc69bd04
|
7
|
+
data.tar.gz: 6d5a756fa71239e7b7cbc734d7ca1227388d17581491c153a146ae7f6828859dc4bc6ae4edbd674fb981161a0e7c803a0e5cf54f06ca48a483858188a551fc0e
|
data/Gemfile.lock
CHANGED
data/lib/arql/ext/array.rb
CHANGED
@@ -14,13 +14,26 @@ class Array
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def v
|
17
|
-
|
18
|
-
raise 'All elements must be instances of the same ActiveRecord model class' unless map(&:class).uniq.size == 1 && first.is_a?(ActiveRecord::Base)
|
17
|
+
return self unless present?
|
19
18
|
t = []
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
if map(&:class).uniq.size == 1
|
20
|
+
if first.is_a?(ActiveRecord::Base)
|
21
|
+
t << first.attribute_names
|
22
|
+
t << nil
|
23
|
+
each do |e|
|
24
|
+
t << e.attributes.values_at(*first.attribute_names).map(&:as_json)
|
25
|
+
end
|
26
|
+
elsif first.is_a?(Array)
|
27
|
+
t = map { |a| a.map(&:as_json) }
|
28
|
+
elsif first.is_a?(Hash) || first.is_a?(ActiveSupport::HashWithIndifferentAccess)
|
29
|
+
t << first.keys
|
30
|
+
t << nil
|
31
|
+
each do |e|
|
32
|
+
t << e.values_at(*first.keys).map(&:as_json)
|
33
|
+
end
|
34
|
+
else
|
35
|
+
return self
|
36
|
+
end
|
24
37
|
end
|
25
38
|
t
|
26
39
|
end
|
data/lib/arql/version.rb
CHANGED