paramore 1.0.3 → 1.1.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 +4 -4
- data/lib/paramore/extension.rb +19 -8
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a45a04ffeaabb270fd7b57a2e27e195205a26ad281c46d69561040d71fb6961
|
4
|
+
data.tar.gz: 0df60483be44946c6e1fedb711039d5a915787c54e46c5f841c73172393e35f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0f3ed2da9f139467f5d4f6db3d7cbc7f0b29c3c1385a4eb8835d0cbffced915d0c77700d69722d11807984624e611856b2acd36462fe6ea4cb577736f8c6255
|
7
|
+
data.tar.gz: decf8bc3cbaa99c75ce7070b59f58f4e84d5cd0b3d22681836ae56f61596a600f3777e58c929d9db31a698689ea07a7b00330d45f54a9706262b512734b07393
|
data/lib/paramore/extension.rb
CHANGED
@@ -4,10 +4,16 @@ require_relative 'permitted_parameter_argument'
|
|
4
4
|
|
5
5
|
module Paramore
|
6
6
|
module Extension
|
7
|
-
|
7
|
+
OPTIONS = %i[
|
8
|
+
default
|
9
|
+
].freeze
|
10
|
+
|
11
|
+
def paramorize(accessor_name, configuration)
|
12
|
+
parameter_configuration = configuration.except(*OPTIONS)
|
13
|
+
|
8
14
|
unless parameter_configuration.keys.size == 1
|
9
15
|
raise ArgumentError,
|
10
|
-
"Paramore: exactly one required attribute allowed! Given: #{
|
16
|
+
"Paramore: exactly one required attribute allowed! Given: #{parameter_configuration.keys}"
|
11
17
|
end
|
12
18
|
|
13
19
|
required_parameter_name = parameter_configuration.keys.first
|
@@ -15,15 +21,20 @@ module Paramore
|
|
15
21
|
|
16
22
|
Paramore::Validate.run(types_definition) if types_definition.is_a?(Hash)
|
17
23
|
|
24
|
+
permitted_parameter_argument =
|
25
|
+
if types_definition.is_a?(Hash)
|
26
|
+
Paramore::PermittedParameterArgument.parse(types_definition)
|
27
|
+
else
|
28
|
+
types_definition
|
29
|
+
end
|
30
|
+
|
18
31
|
define_method(accessor_name) do |rails_parameters = params|
|
19
32
|
return instance_variable_get("@#{accessor_name}") if instance_variable_defined?("@#{accessor_name}")
|
20
33
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
types_definition
|
26
|
-
end
|
34
|
+
if rails_parameters[required_parameter_name].nil? && configuration[:default]
|
35
|
+
instance_variable_set("@#{accessor_name}", configuration[:default])
|
36
|
+
return instance_variable_get("@#{accessor_name}")
|
37
|
+
end
|
27
38
|
|
28
39
|
permitted_params = rails_parameters
|
29
40
|
.require(required_parameter_name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paramore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Kairevičius
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-rails
|
@@ -101,7 +101,7 @@ licenses:
|
|
101
101
|
- MIT
|
102
102
|
metadata: {}
|
103
103
|
post_install_message: |
|
104
|
-
Thank you for installing Paramore 1.0
|
104
|
+
Thank you for installing Paramore 1.1.0 !
|
105
105
|
From the command line you can run `paramore` to generate a configuration file
|
106
106
|
|
107
107
|
More details here : https://github.com/lumzdas/paramore/blob/master/README.md
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
|
-
rubygems_version: 3.
|
123
|
+
rubygems_version: 3.0.8
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: A declarative approach to Rails' strong parameter typing and sanitizing
|