ae-be_strong 0.1.0 → 0.1.1.pre
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/be_strong/code.rb +10 -11
- data/lib/be_strong/strong_parameter.rb +1 -1
- data/lib/be_strong/strong_parameter_methods.rb +2 -2
- data/lib/be_strong/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0ce40dc3382599f57c34cf38ad2f34a7b790fbd
|
4
|
+
data.tar.gz: 5b53795c6a0c9e2c0ad1ed0a8a3ff71c6f3e9e6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02e9ded8c51d7355bac7702ad52bbf0132e6c47c1b8487d7d57707f169c3a17e0ceeaedb13b40ad63cd51627f4db905cb7b65801e402282bf1c85e403a7abf12
|
7
|
+
data.tar.gz: ef08a33f389eab3f630a3f61dc7f6c92a2966e0b65bf638dde0e74b6acfdb10550ea9f0ec0f4bf708ad2b3dbf9cf3bcfe67a5520bd1b9ae564beabed1ae0ec38
|
data/lib/be_strong/code.rb
CHANGED
@@ -2,7 +2,7 @@ module BeStrong
|
|
2
2
|
class Code
|
3
3
|
include Comparable
|
4
4
|
|
5
|
-
REG_MASS_ASSIGNMENT_METHOD = /((new|build|build_.*|update|update!|assign_attributes|update_attributes|update_attributes!)([\( )])params\[:(\w*)\])/
|
5
|
+
REG_MASS_ASSIGNMENT_METHOD = /((new|build|build_.*|update|update!|assign_attributes|update_attributes|update_attributes!)([\( )])params\[:(\w*)\]([\( )]))/
|
6
6
|
|
7
7
|
def initialize(code)
|
8
8
|
@code = code
|
@@ -15,7 +15,7 @@ module BeStrong
|
|
15
15
|
code.gsub!(REG_MASS_ASSIGNMENT_METHOD) do
|
16
16
|
if StrongParameterMethods.method_for($4)
|
17
17
|
models << $4
|
18
|
-
"#{$2}#{$3}#{$4}_params"
|
18
|
+
"#{$2}#{$3}#{$4}_params#{$5}"
|
19
19
|
else
|
20
20
|
$1
|
21
21
|
end
|
@@ -31,10 +31,10 @@ module BeStrong
|
|
31
31
|
method = StrongParameterMethods.method_for(model)
|
32
32
|
next unless method
|
33
33
|
|
34
|
-
next if code
|
34
|
+
next if code =~ /\bdef #{model}_params\b/
|
35
35
|
|
36
|
-
code.sub!(
|
37
|
-
"
|
36
|
+
code.sub!(/\bprivate\b/) do
|
37
|
+
"private\n\n#{method.gsub(/^/, ' ').chomp}"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -42,12 +42,11 @@ module BeStrong
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def add_private!
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
45
|
+
return code if code =~ /\bprivate\b/
|
46
|
+
code.sub!(/\bend\s*\z/) do
|
47
|
+
"\n private\nend\n"
|
49
48
|
end
|
50
|
-
|
49
|
+
code
|
51
50
|
end
|
52
51
|
|
53
52
|
def remove_attr_accessible_and_protected!
|
@@ -62,7 +61,7 @@ module BeStrong
|
|
62
61
|
code != @original
|
63
62
|
end
|
64
63
|
|
65
|
-
def
|
64
|
+
def to_s
|
66
65
|
code
|
67
66
|
end
|
68
67
|
|
@@ -20,8 +20,8 @@ module BeStrong
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def accessible_attributes
|
23
|
-
|
24
|
-
return
|
23
|
+
accessible = @klass.accessible_attributes
|
24
|
+
return accessible if accessible.size.nonzero?
|
25
25
|
|
26
26
|
@klass.attribute_names - @klass.protected_attributes.to_a
|
27
27
|
end
|
data/lib/be_strong/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ae-be_strong
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AppFolio
|
@@ -150,9 +150,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
152
|
requirements:
|
153
|
-
- - "
|
153
|
+
- - ">"
|
154
154
|
- !ruby/object:Gem::Version
|
155
|
-
version:
|
155
|
+
version: 1.3.1
|
156
156
|
requirements: []
|
157
157
|
rubyforge_project:
|
158
158
|
rubygems_version: 2.5.2
|