attribeauty 0.4.5 → 0.4.7

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
2
  SHA256:
3
- metadata.gz: 374ded7327851e372722c4b501033f42dff9d55d9c0f2c2c1f76b897a12684dd
4
- data.tar.gz: 7f3ad264240f23741939149d3d6583ddcf2087fa5c6482665b0e31992177b108
3
+ metadata.gz: c3e7fb42086d75e28fa5c80ff5718c7de734759a0bce85df5b3fd48a2fabbbaf
4
+ data.tar.gz: 2a08c818e591cd8b4a780d275f2323c76842c7095a2de878bda7bfaab357ef0c
5
5
  SHA512:
6
- metadata.gz: 5905f649b65f1b9056459a9da1c499130c2aac5e4f5aa62185d1c3d6b610832ed89317930b0036b2f243f653ce867d9823b382e9880124e526012e1271087e73
7
- data.tar.gz: 6d42d7c5cd9cfec6313d832892289ddc87b75dbb07f2d636addb5b7a2a64e3579ede93ba7080b07f5dbdacbccc489dd31e66df4a5c186cfcb8c00aa8302b960b
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- attribeauty (0.4.5)
4
+ attribeauty (0.4.7)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Attribeauty
4
- VERSION = "0.4.5"
4
+ VERSION = "0.4.7"
5
5
  end
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.5
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-06-27 00:00:00.000000000 Z
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: