ae-be_strong 0.1.1.pre → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ae-be_strong.rb +1 -0
- data/lib/be_strong/code.rb +11 -10
- 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 +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b15e41e82072f7434239a3f1b2d0e40e25cc2c4
|
4
|
+
data.tar.gz: e16b179ec4b3695cd3bdbe898bd593262e4316bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4cf60d883d4ee03f4127811a0626c7f4106df39fa548bfffbba5ab8283c368c3f1db84ac667d123ff3005abef6b640c558aefffd68676707c2e6f4ca7182193
|
7
|
+
data.tar.gz: 58c5dae5ab066613833d3024706a03946513ac4ed434518a5cc3caff3f2e233c644d800b7818be06918c83c2a2f982bed71f72970b7c7fcb7aaddbf714f36d68
|
data/lib/ae-be_strong.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "be_strong"
|
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"
|
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.include?("def #{model}_params")
|
35
35
|
|
36
|
-
code.sub!(
|
37
|
-
"private\n\n#{method.gsub(/^/, ' ').chomp}"
|
36
|
+
code.sub!(/^ private$/) do
|
37
|
+
" private\n\n#{method.gsub(/^/, ' ').chomp}"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -42,11 +42,12 @@ module BeStrong
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def add_private!
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
unless code.include?('private')
|
46
|
+
code.sub!(/^end/) do
|
47
|
+
"\n private\nend"
|
48
|
+
end
|
48
49
|
end
|
49
|
-
|
50
|
+
self
|
50
51
|
end
|
51
52
|
|
52
53
|
def remove_attr_accessible_and_protected!
|
@@ -61,7 +62,7 @@ module BeStrong
|
|
61
62
|
code != @original
|
62
63
|
end
|
63
64
|
|
64
|
-
def
|
65
|
+
def to_str
|
65
66
|
code
|
66
67
|
end
|
67
68
|
|
@@ -20,8 +20,8 @@ module BeStrong
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def accessible_attributes
|
23
|
-
|
24
|
-
return
|
23
|
+
accssible = @klass.accessible_attributes
|
24
|
+
return accssible if accssible.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.1
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AppFolio
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- be_strong.gemspec
|
127
127
|
- bin/console
|
128
128
|
- bin/setup
|
129
|
+
- lib/ae-be_strong.rb
|
129
130
|
- lib/be_strong.rb
|
130
131
|
- lib/be_strong/attr_accessible.rb
|
131
132
|
- lib/be_strong/code.rb
|
@@ -150,9 +151,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
151
|
version: '0'
|
151
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
153
|
requirements:
|
153
|
-
- - "
|
154
|
+
- - ">="
|
154
155
|
- !ruby/object:Gem::Version
|
155
|
-
version:
|
156
|
+
version: '0'
|
156
157
|
requirements: []
|
157
158
|
rubyforge_project:
|
158
159
|
rubygems_version: 2.5.2
|