drillbit 2.7.0 → 2.8.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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/drillbit/authorizable_resource.rb +14 -5
- data/lib/drillbit/authorizers/parameters/resource.rb +24 -6
- data/lib/drillbit/middleware/parameter_parser.rb +10 -1
- data/lib/drillbit/utilities/string.rb +1 -0
- data/lib/drillbit/version.rb +1 -1
- data/spec/drillbit/middleware/parameter_parser_spec.rb +17 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fec9e9fdc03cb3d4b5ec5977ba97e7732979d35e
|
4
|
+
data.tar.gz: 1eb9aeaa0634e5d47e6a6c80e95fbc2124e08900
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86d163daf5b5523fa2d156f093a8ea257591e15ae155138a6c6b147fb9e34eb8c11d3cfb136481f8cc0f40c932a456c7514caae7ad5c64e6effe92191e733eb0
|
7
|
+
data.tar.gz: 00471ebf723e9042d801d66e2dfa27847bb7a11b3314a57c391d99402cfdc3b0486652555b466ea55fa80ad8803765f642cbdc1fc702a7fe7984028c64a9cba1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -101,7 +101,7 @@ module AuthorizableResource
|
|
101
101
|
call
|
102
102
|
end
|
103
103
|
|
104
|
-
# rubocop:disable Metrics/AbcSize
|
104
|
+
# rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
|
105
105
|
def authorized_attributes
|
106
106
|
@authorized_attributes ||= begin
|
107
107
|
attributes = authorized_params.
|
@@ -114,11 +114,20 @@ module AuthorizableResource
|
|
114
114
|
fetch(:data, {}).
|
115
115
|
fetch(:relationships, authorized_params.class.new).
|
116
116
|
each_pair do |name, relationship|
|
117
|
-
|
118
117
|
if relationship[:data].is_a?(Array)
|
119
|
-
|
118
|
+
if (relationship[:data][0] || {})[:attributes]
|
119
|
+
relationships["#{name}_attributes"] = relationship[:data].map do |datum|
|
120
|
+
attrs = datum[:attributes].dup
|
121
|
+
|
122
|
+
attrs.delete(:__id__)
|
123
|
+
|
124
|
+
attrs
|
125
|
+
end
|
126
|
+
else
|
127
|
+
attribute = "#{Drillbit::Utilities::String.singularize(name)}_ids".to_sym
|
120
128
|
|
121
|
-
|
129
|
+
relationships[attribute] = relationship[:data].map { |datum| datum[:id] }
|
130
|
+
end
|
122
131
|
elsif relationship[:data].nil? || relationship[:data].is_a?(Hash)
|
123
132
|
attribute = name.to_sym
|
124
133
|
|
@@ -131,7 +140,7 @@ module AuthorizableResource
|
|
131
140
|
end
|
132
141
|
end
|
133
142
|
end
|
134
|
-
# rubocop:enable
|
143
|
+
# rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity
|
135
144
|
|
136
145
|
def authorized_resource
|
137
146
|
return nil if RESOURCE_COLLECTION_ACTIONS.include?(action_name)
|
@@ -51,19 +51,37 @@ class Resource < Authorizers::Parameters
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
# rubocop:disable Metrics/AbcSize
|
55
|
+
def add_authorized_relationship(name, embedded_attributes: {})
|
56
|
+
param = params.
|
57
|
+
fetch(:data, {}).
|
58
|
+
fetch(:relationships, {}).
|
59
|
+
fetch(name, {}).
|
60
|
+
fetch(:data, nil)
|
61
|
+
first = params.
|
62
|
+
fetch(:data, {}).
|
63
|
+
fetch(:relationships, {}).
|
64
|
+
fetch(name, {}).
|
65
|
+
fetch(:data, []).
|
66
|
+
first || {}
|
67
|
+
embedded = first.fetch(:attributes, nil)
|
60
68
|
|
61
69
|
if param.nil?
|
62
70
|
authorized_params[6][:data][2][:relationships][name] = [:data]
|
71
|
+
elsif embedded
|
72
|
+
authorized_params[6][:data][2][:relationships][name] = {
|
73
|
+
data: [
|
74
|
+
:type,
|
75
|
+
{
|
76
|
+
attributes: %i{__id__} + embedded_attributes,
|
77
|
+
},
|
78
|
+
],
|
79
|
+
}
|
63
80
|
else
|
64
81
|
authorized_params[6][:data][2][:relationships][name] = { data: %i{type id} }
|
65
82
|
end
|
66
83
|
end
|
84
|
+
# rubocop:enable Metrics/AbcSize
|
67
85
|
|
68
86
|
def add_authorized_relationships(*names)
|
69
87
|
names.each do |name|
|
@@ -59,7 +59,16 @@ class ParameterParser
|
|
59
59
|
return parameters unless parameters.is_a? Hash
|
60
60
|
|
61
61
|
parameters.each_with_object({}) do |(key, value), hash|
|
62
|
-
value =
|
62
|
+
value = case value
|
63
|
+
when Hash
|
64
|
+
underscore_parameters(value)
|
65
|
+
when Array
|
66
|
+
value.map do |item|
|
67
|
+
underscore_parameters(item)
|
68
|
+
end
|
69
|
+
else
|
70
|
+
value
|
71
|
+
end
|
63
72
|
|
64
73
|
hash[Drillbit::Utilities::String.underscore(key)] = value
|
65
74
|
end
|
data/lib/drillbit/version.rb
CHANGED
@@ -96,7 +96,15 @@ describe ParameterParser do
|
|
96
96
|
"quad": {
|
97
97
|
"another-level": "whoa inception"
|
98
98
|
}
|
99
|
-
}
|
99
|
+
},
|
100
|
+
"quint": [
|
101
|
+
{
|
102
|
+
"quint-it-quit": "mc-dipple"
|
103
|
+
},
|
104
|
+
{
|
105
|
+
"quint-it-quit": "big-maccle"
|
106
|
+
}
|
107
|
+
]
|
100
108
|
}
|
101
109
|
HEREDOC
|
102
110
|
}
|
@@ -112,6 +120,14 @@ describe ParameterParser do
|
|
112
120
|
'another_level' => 'whoa inception',
|
113
121
|
},
|
114
122
|
},
|
123
|
+
'quint' => [
|
124
|
+
{
|
125
|
+
'quint_it_quit' => 'mc-dipple',
|
126
|
+
},
|
127
|
+
{
|
128
|
+
'quint_it_quit' => 'big-maccle',
|
129
|
+
},
|
130
|
+
],
|
115
131
|
)
|
116
132
|
end
|
117
133
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drillbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thegranddesign
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
zRIv8lqQM8QFT76rzP5SBCERwN+ltKAFbQ5/FwmZNGWYnmCP3RZMQiRnbh+9H9lh
|
32
32
|
mlbwaYZTjgsXq6cy8N38EecewgBbZYS1IYJraE/M
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-10-
|
34
|
+
date: 2016-10-28 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: erratum
|
metadata.gz.sig
CHANGED
Binary file
|