sudo_attr_accessibility 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/PostInstall.txt +1 -0
- data/README.md +1 -76
- data/lib/sudo_attr_accessibility/version.rb +1 -1
- data/sudo_attr_accessibility.gemspec +4 -2
- metadata +26 -14
data/PostInstall.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
WARNING: This gem was renamed to su_attr_accessibility (see https://github.com/eval/su_attr_accessibility). Please update your dependencies!
|
data/README.md
CHANGED
@@ -1,78 +1,3 @@
|
|
1
1
|
# SudoAttrAccessibility
|
2
2
|
|
3
|
-
|
4
|
-
As of Rails 3.1 this got even better as you can define different lists of attributes for different roles.
|
5
|
-
|
6
|
-
While this is all good and fine to protect your models from malicious input from outside (handled mostly in controllers), it will also make other interactions with your models somewhat harder: e.g. when testing or when in the console you always have to pass a role which can access the correct attributes.
|
7
|
-
|
8
|
-
This gem tries to solve this by letting you define roles that are allowed to access all attribites. It even makes it possible to forget all this role-stuff and only explicitly use roles in places where it matters (again: mostly in controllers).
|
9
|
-
|
10
|
-
## Installation
|
11
|
-
|
12
|
-
Add this line to your application's Gemfile:
|
13
|
-
|
14
|
-
gem 'sudo_attr_accessibility'
|
15
|
-
|
16
|
-
And then execute:
|
17
|
-
|
18
|
-
$ bundle
|
19
|
-
|
20
|
-
Or install it yourself as:
|
21
|
-
|
22
|
-
$ gem install sudo_attr_accessibility
|
23
|
-
|
24
|
-
## Usage
|
25
|
-
|
26
|
-
```ruby
|
27
|
-
class Person < ActiveRecord::Base
|
28
|
-
belongs_to :account
|
29
|
-
|
30
|
-
# attributes mass-assignable as role default
|
31
|
-
attr_accessible :email
|
32
|
-
|
33
|
-
# the admin-role can access all...
|
34
|
-
sudo_attr_accessible_as :admin
|
35
|
-
|
36
|
-
# ...even attributes defined later on
|
37
|
-
attr_accessor :current_step
|
38
|
-
end
|
39
|
-
|
40
|
-
p1 = Person.new(:email => 'person1@example.org', :active => true)
|
41
|
-
p1.email # => 'person1@example.org'
|
42
|
-
p1.active # => nil
|
43
|
-
p2 = Person.new({:email => 'person1@example.org', :active => true,
|
44
|
-
:account => Account.first, :current_step => 1},
|
45
|
-
:as => :admin)
|
46
|
-
p2.email # => 'person1@example.org'
|
47
|
-
p2.active # => true
|
48
|
-
p2.current_step # => 2
|
49
|
-
p2.account # => <Account ...>
|
50
|
-
```
|
51
|
-
|
52
|
-
Alternatively the default-role is passed to sudo_attr_accessible_as and
|
53
|
-
another role is used for attr_accessible. This is more convenient when
|
54
|
-
working in the console for example (no ':as => :role' is needed) though
|
55
|
-
is less secure of course.
|
56
|
-
|
57
|
-
Enabling this behaviour by default for all subclasses of AR:
|
58
|
-
|
59
|
-
```ruby
|
60
|
-
class ActiveRecord::Base
|
61
|
-
def self.inherited(child_class)
|
62
|
-
child_class.class_eval{ sudo_attr_accessible_as :default }
|
63
|
-
super
|
64
|
-
end
|
65
|
-
end
|
66
|
-
```
|
67
|
-
|
68
|
-
## Contributing
|
69
|
-
|
70
|
-
1. Fork it
|
71
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
72
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
73
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
74
|
-
5. Create new Pull Request
|
75
|
-
|
76
|
-
## Author
|
77
|
-
|
78
|
-
Gert Goet (eval) :: gert@thinkcreate.nl :: @gertgoet
|
3
|
+
This gem is renamed to su_attr_accessibility. See https://github.com/eval/su_attr_accessibility
|
@@ -4,10 +4,11 @@ require File.expand_path('../lib/sudo_attr_accessibility/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Gert Goet"]
|
6
6
|
gem.email = ["gert@thinkcreate.nl"]
|
7
|
-
gem.description = %q{
|
8
|
-
gem.summary = %q{
|
7
|
+
gem.description = %q{See su_attr_accessibility}
|
8
|
+
gem.summary = %q{See su_attr_accessibility}
|
9
9
|
gem.homepage = "https://github.com/eval/sudo_attr_accessibility"
|
10
10
|
gem.license = "MIT"
|
11
|
+
gem.post_install_message = "PostInstall.txt"
|
11
12
|
|
12
13
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
13
14
|
gem.files = `git ls-files`.split("\n")
|
@@ -19,6 +20,7 @@ Gem::Specification.new do |gem|
|
|
19
20
|
|
20
21
|
gem.add_dependency "activesupport", ">= 3.0.0"
|
21
22
|
gem.add_dependency "activemodel", ">= 3.0.0"
|
23
|
+
gem.add_dependency "su_attr_accessibility", ">= 0.5.0"
|
22
24
|
|
23
25
|
gem.add_development_dependency "rspec", "~> 2.7.0"
|
24
26
|
gem.add_development_dependency "ZenTest", "~> 4.6.2"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sudo_attr_accessibility
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-05 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &70336822218720 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70336822218720
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activemodel
|
27
|
-
requirement: &
|
27
|
+
requirement: &70336822216880 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,21 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70336822216880
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: su_attr_accessibility
|
38
|
+
requirement: &70336822215620 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.5.0
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70336822215620
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: rspec
|
38
|
-
requirement: &
|
49
|
+
requirement: &70336822214540 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ~>
|
@@ -43,10 +54,10 @@ dependencies:
|
|
43
54
|
version: 2.7.0
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *70336822214540
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
59
|
name: ZenTest
|
49
|
-
requirement: &
|
60
|
+
requirement: &70336822213440 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ~>
|
@@ -54,8 +65,8 @@ dependencies:
|
|
54
65
|
version: 4.6.2
|
55
66
|
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
58
|
-
description:
|
68
|
+
version_requirements: *70336822213440
|
69
|
+
description: See su_attr_accessibility
|
59
70
|
email:
|
60
71
|
- gert@thinkcreate.nl
|
61
72
|
executables: []
|
@@ -65,6 +76,7 @@ files:
|
|
65
76
|
- .gitignore
|
66
77
|
- Gemfile
|
67
78
|
- LICENSE
|
79
|
+
- PostInstall.txt
|
68
80
|
- README.md
|
69
81
|
- Rakefile
|
70
82
|
- lib/sudo_attr_accessibility.rb
|
@@ -76,7 +88,7 @@ files:
|
|
76
88
|
homepage: https://github.com/eval/sudo_attr_accessibility
|
77
89
|
licenses:
|
78
90
|
- MIT
|
79
|
-
post_install_message:
|
91
|
+
post_install_message: PostInstall.txt
|
80
92
|
rdoc_options: []
|
81
93
|
require_paths:
|
82
94
|
- lib
|
@@ -94,13 +106,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
106
|
version: '0'
|
95
107
|
segments:
|
96
108
|
- 0
|
97
|
-
hash:
|
109
|
+
hash: 2223899480655262526
|
98
110
|
requirements: []
|
99
111
|
rubyforge_project:
|
100
112
|
rubygems_version: 1.8.10
|
101
113
|
signing_key:
|
102
114
|
specification_version: 3
|
103
|
-
summary:
|
115
|
+
summary: See su_attr_accessibility
|
104
116
|
test_files:
|
105
117
|
- spec/spec.opts
|
106
118
|
- spec/spec_helper.rb
|