pattern_query_helper 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fc3542480086bfce27b1b1297b20bd82d655603a
4
- data.tar.gz: b4889e7e143947c09ff285c5284534403bfe9349
2
+ SHA256:
3
+ metadata.gz: 38dc301a4cb672d6462a7e7b94284493b46718ed016f68c0c3282a9233abf2fc
4
+ data.tar.gz: f41c477445fcdda1d57e8e76b40cac7c9acc9f88da328d82040c7ecdad062e08
5
5
  SHA512:
6
- metadata.gz: 13def542cea53e4ae17a11e6954aa05a50a54615a9181db57e7998f92587539b885c0e6d4df3e222906c227e4382ff0cf6a998ca31656b7af53c0c4e73178554
7
- data.tar.gz: 54d9ad702a2acfc25c98494508c80f77f7d0812b406209bac4aff166314e36c16fd3f2fb2a0c290860d2520e14643b7fc05f3379669ade21fbae9147eb7b535e
6
+ metadata.gz: 2dd92c57a1dcab50677649498fde26983f685899e10f096bbce573544420ae0c3c7736b22836d1e8c8ccd6450a7f33c6ebce5f1b03f69eb2b41fca9357a13eb0
7
+ data.tar.gz: 5a062958f9d86f8264fa86b5914a7f958940a39c743d9d8f62dd4f2c4ee4db14d26543436075400d04e2c33e1cf858cc6723f59083d736ab1a892d2b41a6d931
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ .byebug_history
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pattern_query_helper (0.2.2)
4
+ pattern_query_helper (0.2.3)
5
5
  activerecord (~> 5.0)
6
6
  kaminari (~> 1.1.1)
7
7
 
@@ -27,6 +27,7 @@ GEM
27
27
  tzinfo (~> 1.1)
28
28
  arel (9.0.0)
29
29
  builder (3.2.3)
30
+ byebug (11.0.1)
30
31
  concurrent-ruby (1.1.4)
31
32
  crass (1.0.4)
32
33
  diff-lcs (1.3)
@@ -83,6 +84,7 @@ PLATFORMS
83
84
 
84
85
  DEPENDENCIES
85
86
  bundler (~> 1.16)
87
+ byebug
86
88
  faker (~> 1.9.3)
87
89
  pattern_query_helper!
88
90
  rake (~> 10.0)
@@ -3,15 +3,33 @@ module PatternQueryHelper
3
3
  def self.process_association_params(associations)
4
4
  associations ||= []
5
5
  if associations.class == String
6
- return [associations.to_sym]
6
+ [associations.to_sym]
7
7
  else
8
- return associations.map { |x| x.to_sym }
8
+ associations
9
9
  end
10
10
  end
11
11
 
12
12
  def self.load_associations(payload, associations)
13
13
  ActiveRecord::Associations::Preloader.new.preload(payload, associations)
14
- payload.as_json(include: associations)
14
+ payload.as_json(include: json_associations(associations))
15
+ end
16
+
17
+ def self.json_associations(associations)
18
+ associations ||= []
19
+ associations = associations.is_a?(Array) ? associations : [associations]
20
+ associations.inject([]) do |translated, association|
21
+ if association.is_a?(Symbol) || association.is_a?(String)
22
+ translated << association.to_sym
23
+ elsif association.is_a?(Array)
24
+ translated << association.map(&:to_sym)
25
+ elsif association.is_a?(Hash)
26
+ translated_hash = {}
27
+ association.each do |key, value|
28
+ translated_hash[key.to_sym] = { include: json_associations(value) }
29
+ end
30
+ translated << translated_hash
31
+ end
32
+ end
15
33
  end
16
34
  end
17
35
  end
@@ -1,3 +1,3 @@
1
1
  module PatternQueryHelper
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -41,6 +41,7 @@ Gem::Specification.new do |spec|
41
41
  spec.add_development_dependency "rspec", "~> 3.0"
42
42
  spec.add_development_dependency "sqlite3", "~> 1.3.6"
43
43
  spec.add_development_dependency "faker", "~> 1.9.3"
44
+ spec.add_development_dependency "byebug"
44
45
 
45
46
  spec.add_dependency "activerecord", "~> 5.0"
46
47
  spec.add_dependency "kaminari", "~> 1.1.1"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pattern_query_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan McDaniel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-06 00:00:00.000000000 Z
11
+ date: 2019-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.9.3
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: activerecord
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -155,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
169
  version: '0'
156
170
  requirements: []
157
171
  rubyforge_project:
158
- rubygems_version: 2.6.14
172
+ rubygems_version: 2.7.6
159
173
  signing_key:
160
174
  specification_version: 4
161
175
  summary: Ruby Gem to help with pagination and data formatting at Pattern, Inc.