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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85fcbdbbbb1fb63922b682ab5e666510d22305e59606379db57dca8d04eebf26
4
- data.tar.gz: 3176979b46fd4021f149aa6c04ea44b5ddb76a522b065d89d7cb6c82ce37ed7f
3
+ metadata.gz: e38b5865065ed505f7b673f61ad896ff1705334311f559d23124b9c73eae4832
4
+ data.tar.gz: bd5fc96a17c9ebd68d158da1a867e7f6f40c398caaa647bc3c2512cefa4aa311
5
5
  SHA512:
6
- metadata.gz: 575529d3c8aaa704aba90b1626310263e2900a13619637da651e3a4611f514c81bac68032d63955b082952539d7e4dcec77adbd902739584ef3924b83f1945c0
7
- data.tar.gz: 479fbf975df4afb3d60068ad7bde49cb3167da461369cd0476b2867674b98e82ac44f8e512e15885724f69a238c80f2314d765a648680a76bb1791a6f7ff9659
6
+ metadata.gz: adce379a72d895d75ccfa1b2f29da270efb64237b3bcaec2a016d163631dcc09e674e2cb88920a44d53eb80551742b6a68d5385dbd8c7e2b43ddaa8bdc69bd04
7
+ data.tar.gz: 6d5a756fa71239e7b7cbc734d7ca1227388d17581491c153a146ae7f6828859dc4bc6ae4edbd674fb981161a0e7c803a0e5cf54f06ca48a483858188a551fc0e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- arql (0.1.12)
4
+ arql (0.1.13)
5
5
  activerecord (~> 6.0.3)
6
6
  activesupport (~> 6.0.3)
7
7
  mysql2 (~> 0.5.3)
@@ -14,13 +14,26 @@ class Array
14
14
  end
15
15
 
16
16
  def v
17
- raise 'Empty array' unless present?
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
- t << first.attribute_names
21
- t << nil
22
- each do |e|
23
- t << e.attributes.values_at(*first.attribute_names).map(&:as_json)
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
@@ -1,3 +1,3 @@
1
1
  module Arql
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.13"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liu Xiang