attribeauty 0.4.4 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -4
- data/lib/attribeauty/params.rb +15 -1
- data/lib/attribeauty/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e043b4e5f8fcbdfd096c6cd5deabfca25667b5c0e3a2754b8106f250e12569cd
|
4
|
+
data.tar.gz: 450ccb28494f3b5dbde4d3f56113997bf5d3e85dfb6fee82a1f683ca85e7523e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a44271c47fdec0e64fcfa8bae79b426d88a67b3c5eae25201c7ce675f1b9188308dfb5c13df908c3701bef1f7350bf786becf0d395b6ff5ce918d2706f4a6bed
|
7
|
+
data.tar.gz: '048046380ad6ac7c65b7406beeb222ee553beea2bed15ea2b855dfdac4b19243537046caeb579d21eb3d536b3e758323f38e6cfb0cbec8d8fea90284331aca00'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.4.6] - 2024-06-28
|
4
|
+
|
5
|
+
- unofficial support for auto generating rails models params filtering
|
6
|
+
- no tests, and simply a script I'm using in an app to do the same
|
7
|
+
|
8
|
+
## [0.4.5] - 2024-06-27
|
9
|
+
|
10
|
+
- using `root` instead of `container`, this is what serializers use
|
11
|
+
|
3
12
|
## [0.4.4] - 2024-06-26
|
4
13
|
|
5
14
|
- get `default:` working. Not expecting to use them since db will handle that, but nice to have?
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -133,12 +133,12 @@ class MyController
|
|
133
133
|
Attribeauty::Params.with(request.params)
|
134
134
|
end
|
135
135
|
|
136
|
-
# using
|
136
|
+
# using root will exclude the value and yield:
|
137
137
|
# { title: "woo", email: { address: "hmm@yep.com" } }
|
138
138
|
#
|
139
139
|
def update_params
|
140
140
|
params_filter.accept do
|
141
|
-
|
141
|
+
root :user do
|
142
142
|
attribute :title, :string, required: true
|
143
143
|
attribute :email do
|
144
144
|
attribute :address, :string, exclude_if: [:empty?, :nil?]
|
@@ -177,7 +177,7 @@ class MyController
|
|
177
177
|
#
|
178
178
|
def update_params
|
179
179
|
params_filter.accept! do
|
180
|
-
|
180
|
+
root :user do
|
181
181
|
attribute :title, :string, exclude_if: :nil?, required: true
|
182
182
|
attribute :email do
|
183
183
|
attribute :address, :string
|
@@ -215,7 +215,7 @@ class MyController
|
|
215
215
|
#
|
216
216
|
def update_params
|
217
217
|
params_filter.accept exclude_if: :nil?, required: true do
|
218
|
-
|
218
|
+
root :user do
|
219
219
|
attribute :title, :string,
|
220
220
|
attribute :email do
|
221
221
|
attribute :address, :string
|
data/lib/attribeauty/params.rb
CHANGED
@@ -43,7 +43,7 @@ module Attribeauty
|
|
43
43
|
to_h[key] = value
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
46
|
+
def root(name)
|
47
47
|
@request_params = request_params[name]
|
48
48
|
|
49
49
|
yield
|
@@ -68,6 +68,20 @@ module Attribeauty
|
|
68
68
|
strict
|
69
69
|
end
|
70
70
|
|
71
|
+
def generate_for(model, *columns)
|
72
|
+
raise "Method requires Rails" unless defined?(Rails)
|
73
|
+
|
74
|
+
root_node = model.to_s.downcase.to_sym
|
75
|
+
cols = columns.map(&:to_s)
|
76
|
+
root root_node do
|
77
|
+
model.columns_hash.slice(*cols).each_value do |table|
|
78
|
+
attrs = table.name.to_sym, table.type
|
79
|
+
attrs << { exclude_if: :nil? } if table.null == false
|
80
|
+
attribute(*attrs)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
71
85
|
private
|
72
86
|
|
73
87
|
def value_from_validator(name, value, type, **args)
|
data/lib/attribeauty/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attribeauty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toby
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: There are so many of these, I just needed this one.
|
14
14
|
email:
|