plutonium 0.6.0 → 0.6.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d16b924e13ab0437254c6f0111f62edcda838595f4c3a4c6d3e901551d1b0f6a
|
4
|
+
data.tar.gz: 4de65c315948d036a0466d3c2566fdea2ee8e00d2db7683fa544eeb34c5eeac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3df5d1ece1f1767ff660487aaa6bcad795849c1abbb3e115332f9703123a81a15be636265ed5a641cb75ff4614f3189d97fc2afe470004ce9e179b888f0c7449
|
7
|
+
data.tar.gz: c293b9ff25e4cf6a554325394e4622a048599fc0dce257a82ff5ac21d9b7115d4fc74ca60fa251b306a3065860b9032afff5a4bcac968a856e0a5505c14e03c9
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Plutonium: Take Your Rails Productivity Nuclear
|
1
|
+
# Plutonium: Take Your Rails Productivity Nuclear🚀
|
2
2
|
|
3
3
|
**Plutonium** picks up where Rails left off, introducing application level concepts and tooling, transforming the way you build applications with Rails.
|
4
4
|
It's a culmination of lessons learned from years of developing nearly identical applications and is designed to save you from the drudgery of re-implementation.
|
data/lib/plutonium/railtie.rb
CHANGED
@@ -94,7 +94,16 @@ module Plutonium
|
|
94
94
|
# [:title, :body, {:images=>[]}, {:docs=>[]}]
|
95
95
|
#
|
96
96
|
def strong_parameters_for(*attributes)
|
97
|
-
|
97
|
+
# {:name=>{:name=>nil}, :body=>{:body=>nil}, :cover_image=>{:cover_image=>nil}, :comments=>{:comment_ids=>[]}}
|
98
|
+
strong_parameters_definition
|
99
|
+
# {:name=>{:name=>nil}, :comments=>{:comment_ids=>[]}, :cover_image=>{:cover_image=>nil}}
|
100
|
+
.slice(*attributes)
|
101
|
+
# [{:name=>nil}, {:comment_ids=>[]}, {:cover_image=>nil}]
|
102
|
+
.values
|
103
|
+
# {:name=>nil, :comment_ids=>[], :cover_image=>nil}
|
104
|
+
.reduce(:merge)
|
105
|
+
# [:name, {:comment_ids=>[]}, :cover_image]
|
106
|
+
.map { |key, value| value.nil? ? key : {key => value} }
|
98
107
|
end
|
99
108
|
|
100
109
|
# Ransack
|
@@ -127,20 +136,28 @@ module Plutonium
|
|
127
136
|
type = [] if column&.try(:array?)
|
128
137
|
type = {} if [:json, :jsonb].include?(column&.type)
|
129
138
|
|
130
|
-
[name, type]
|
139
|
+
[name, {name => type}]
|
131
140
|
end
|
132
141
|
parameters = content_column_parameters.to_h
|
133
142
|
|
134
143
|
# TODO: add nested support
|
135
144
|
|
136
|
-
|
137
|
-
parameters.merge!
|
138
|
-
|
145
|
+
# TODO:
|
146
|
+
parameters.merge! reflect_on_all_associations(:belongs_to)
|
147
|
+
.map { |reflection|
|
148
|
+
input_param = (reflection.respond_to?(:options) && reflection.options[:foreign_key]) || :"#{reflection.name}_id"
|
149
|
+
[reflection.name, {input_param => nil}]
|
150
|
+
}
|
151
|
+
.to_h
|
139
152
|
|
140
|
-
parameters.merge!
|
141
|
-
parameters.merge!
|
153
|
+
parameters.merge! has_one_association_field_names.map { |name| [name, {name => nil}] }.to_h
|
154
|
+
parameters.merge! has_one_attached_field_names.map { |name| [name, {name => nil}] }.to_h
|
142
155
|
|
143
|
-
|
156
|
+
parameters.merge! has_many_association_field_names.map { |name| [name, {"#{name.to_s.singularize}_ids": []}] }.to_h
|
157
|
+
parameters.merge! has_many_attached_field_names.map { |name| [name, {name: []}] }.to_h
|
158
|
+
|
159
|
+
# e.g.
|
160
|
+
# {:name=>{:name=>nil}, :cover_image=>{:cover_image=>nil}, :user=>{:user_id=>nil} :comments=>{:comment_ids=>[]}}
|
144
161
|
parameters
|
145
162
|
end
|
146
163
|
end
|
data/lib/plutonium/version.rb
CHANGED