attribeauty 0.4.5 → 0.4.7
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/CHANGELOG.md +10 -0
- data/Gemfile.lock +1 -1
- data/lib/attribeauty/params.rb +26 -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: c3e7fb42086d75e28fa5c80ff5718c7de734759a0bce85df5b3fd48a2fabbbaf
|
4
|
+
data.tar.gz: 2a08c818e591cd8b4a780d275f2323c76842c7095a2de878bda7bfaab357ef0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 970ede789c687fd334b84555b610940e3862672166269a2b39055c942f79a7466371f4a05d35bc658b5b455914281e5cde607e9a41da84c49e7554d58df935b7
|
7
|
+
data.tar.gz: 2e7a482d54b2487169cb63380eb641a42a3bc03a1fecd25028ed917e2184110bdd658173924de55ff7440c7101c3a93b5f42bf182f2e58c90a6e874ef4406a86
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.4.7] - 2024-07-01
|
4
|
+
|
5
|
+
- generate for fix, and added strict option.
|
6
|
+
- handle stringifying keys with root
|
7
|
+
|
8
|
+
## [0.4.6] - 2024-06-28
|
9
|
+
|
10
|
+
- unofficial support for auto generating rails models params filtering
|
11
|
+
- no tests, and simply a script I'm using in an app to do the same
|
12
|
+
|
3
13
|
## [0.4.5] - 2024-06-27
|
4
14
|
|
5
15
|
- using `root` instead of `container`, this is what serializers use
|
data/Gemfile.lock
CHANGED
data/lib/attribeauty/params.rb
CHANGED
@@ -44,7 +44,7 @@ module Attribeauty
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def root(name)
|
47
|
-
@request_params = request_params[name]
|
47
|
+
@request_params = request_params[name].transform_keys(&:to_sym)
|
48
48
|
|
49
49
|
yield
|
50
50
|
end
|
@@ -68,6 +68,31 @@ module Attribeauty
|
|
68
68
|
strict
|
69
69
|
end
|
70
70
|
|
71
|
+
# in Rails if you have a user model you can call
|
72
|
+
# Attribeauty::Params.with(params.to_unsafe_h).generate_for(User, :username, :name, :age, :email)
|
73
|
+
# It will grab the type, and add an exclude_if: for all with Null false
|
74
|
+
def generate_for(model, *columns)
|
75
|
+
raise "Method requires Rails" unless defined?(Rails)
|
76
|
+
|
77
|
+
root_node = model.to_s.downcase.to_sym
|
78
|
+
cols = columns.map(&:to_s)
|
79
|
+
root root_node do
|
80
|
+
model.columns_hash.slice(*cols).each_value do |table|
|
81
|
+
attrs = table.name.to_sym, table.type
|
82
|
+
attrs << { exclude_if: :nil? } if table.null == false
|
83
|
+
attribute(*attrs)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
self
|
88
|
+
end
|
89
|
+
|
90
|
+
def generate_for!(model, *columns)
|
91
|
+
@strict = true
|
92
|
+
|
93
|
+
generate_for(model, *columns)
|
94
|
+
end
|
95
|
+
|
71
96
|
private
|
72
97
|
|
73
98
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toby
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-01 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:
|