pretty-api 0.4.0 → 0.5.0

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: 9668f43a29b655b7f053e2e225d8d5fd6cc7e40cf51f07d52604d9032056ccf3
4
- data.tar.gz: 587fce31fb41a7c225dea094650750cf91f197f94f32c45d912e8bd730cfb825
3
+ metadata.gz: 994566575dc33d8fae9fd256bceb6dad1b00a92c9c49412fb25dc688784db50e
4
+ data.tar.gz: 1207aa02e765a522870aabffc6b1e16f56f39405c52c790554e867d3e1f0ad61
5
5
  SHA512:
6
- metadata.gz: 1ee8e896e7bb56156361b8e2f3ccfc1fb85409ffd37b447fcf325ebc80216f80dcaf75f5aede2c4eec4c739e924d034e07aa63833126ea5e938763b1d57b5dbe
7
- data.tar.gz: eb77378853a03d88cfa769bde7be327cbc4bc7acd326f32b32ce06b01d0c025f09ae454aa934e9b59d2e29a823bcf3fb1598c16fded819c27633a8069e929b4e
6
+ metadata.gz: e7aed217c780f4bc5fa100590a6a450eda444da755cd1aa180340a0aa1cff8a4ed1b8979a20f23dca219fa71ad19a9a76946573607b9fd0c216b971cd318cd0b
7
+ data.tar.gz: 7fd6148770e4491ebbdc56d598d23da541c8f54e5627437243502a6c0b880a7939cce3820c8771165fea5fe78b52eda980e979b72337935a2187b704fd2439f2
data/.rubocop.yml CHANGED
@@ -9,6 +9,7 @@ require:
9
9
  - rubocop-rails
10
10
  - rubocop-performance
11
11
  - rubocop-rspec
12
+ # - rubocop-factory_bot
12
13
 
13
14
  AllCops:
14
15
  DisabledByDefault: false
@@ -19,8 +20,8 @@ AllCops:
19
20
  - lib/templates/**/*
20
21
  - public/**/*
21
22
 
22
- FactoryBot/ConsistentParenthesesStyle:
23
- EnforcedStyle: omit_parentheses
23
+ #FactoryBot/ConsistentParenthesesStyle:
24
+ # EnforcedStyle: omit_parentheses
24
25
 
25
26
  Layout/LineLength:
26
27
  Exclude:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.5.0] - 2024-06-04
4
+
5
+ - Add new method aliases: `pretty_attrs` and `pretty_errors`
6
+
7
+ ## [0.4.1] - 2024-06-04
8
+
9
+ - Fix `undefined method `each' for nil` when PrettyAPI is used on record that doesn't have associations
10
+
3
11
  ## [0.4.0] - 2024-06-04
4
12
 
5
13
  - Add support for www-form-urlencoded / multipart format: Fix "No implicit conversion of String into Integer"
@@ -16,6 +16,9 @@ module PrettyApi
16
16
 
17
17
  PrettyApi::Errors::NestedErrors.new(nested_tree: attrs).parse(record)
18
18
  end
19
+
20
+ alias_method :pretty_attrs, :pretty_nested_attributes
21
+ alias_method :pretty_errors, :pretty_nested_errors
19
22
  end
20
23
  end
21
24
  end
@@ -6,6 +6,8 @@ module PrettyApi
6
6
  end
7
7
 
8
8
  def parse(record, params)
9
+ return params if nested_tree[record.class].blank?
10
+
9
11
  parse_nested_attributes(record, params, nested_tree[record.class])
10
12
  end
11
13
 
@@ -42,9 +44,7 @@ module PrettyApi
42
44
 
43
45
  (params[assoc_key] || []).each do |p|
44
46
  assoc_primary_key = record.try(:class).try(:primary_key)
45
- assoc = record.try(assoc_key).try(:detect) do |r|
46
- r.try(assoc_primary_key) == p[assoc_primary_key]
47
- end
47
+ assoc = record.try(assoc_key).try(:detect) { |r| r.try(assoc_primary_key) == p[assoc_primary_key] }
48
48
  parse_nested_attributes(assoc, p, nested_tree[assoc_info[:model]])
49
49
  end
50
50
  end
@@ -1,3 +1,3 @@
1
1
  module PrettyApi
2
- VERSION = "0.4.0".freeze
2
+ VERSION = "0.5.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pretty-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James St-Pierre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-04 00:00:00.000000000 Z
11
+ date: 2024-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  requirements: []
73
- rubygems_version: 3.5.9
73
+ rubygems_version: 3.5.11
74
74
  signing_key:
75
75
  specification_version: 4
76
76
  summary: Pretty API for Rails