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: c8fb31a8eb4837634d28b3b0f602b06494991cdcdc02fc600888d0fecf8c497e
4
- data.tar.gz: 4c62d88f641d1890785cac1f6bf483b78e334fd2646bf91b21b3a5a53bd20b2c
3
+ metadata.gz: d16b924e13ab0437254c6f0111f62edcda838595f4c3a4c6d3e901551d1b0f6a
4
+ data.tar.gz: 4de65c315948d036a0466d3c2566fdea2ee8e00d2db7683fa544eeb34c5eeac8
5
5
  SHA512:
6
- metadata.gz: cdc10f0c4d1f23a8fe565968d674d41fd8f9ee0aa43b6a1007ac8bca40897d1f0ee48189230b6aa742d1df53c7055e57eee960a29f265cebeb18160d6b8b73c3
7
- data.tar.gz: 745dfeb89b822d2ba1181050ad3a78de32084361a19664b2f8dc8ab3bbdbff87e4eebae40cec02ebeaed1b966654edab646d6b1570a29eb64147b557ff8d75d8
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.
@@ -1 +1,4 @@
1
- # Configure plutonium here
1
+ # Configure plutonium
2
+
3
+ # Spin up the reactor!
4
+ Plutonium::Reactor::Core.achieve_criticality!
@@ -5,8 +5,6 @@ module Plutonium
5
5
  # add railties here
6
6
 
7
7
  initializer "plutonium.achieve_criticality" do
8
- # get the ball rolling
9
- Plutonium::Reactor::Core.achieve_criticality!
10
8
  end
11
9
  end
12
10
  end
@@ -94,7 +94,16 @@ module Plutonium
94
94
  # [:title, :body, {:images=>[]}, {:docs=>[]}]
95
95
  #
96
96
  def strong_parameters_for(*attributes)
97
- strong_parameters_definition.slice(*attributes).map { |key, value| value.nil? ? key : {key => value} }
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
- parameters.merge! belongs_to_association_field_names.map { |name| [name, nil] }.to_h
137
- parameters.merge! has_one_association_field_names.map { |name| [name, nil] }.to_h
138
- parameters.merge! has_one_attached_field_names.map { |name| [name, nil] }.to_h
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! has_many_association_field_names.map { |name| [name, []] }.to_h
141
- parameters.merge! has_many_attached_field_names.map { |name| [name, []] }.to_h
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
- # e.g. {:title=>nil, :body=>nil, :state=>nil, :created_at=>nil, :updated_at=>nil, :image=>nil, :images=>[]}
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
@@ -1,3 +1,3 @@
1
1
  module Plutonium
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plutonium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Froelich