sudo_attributes 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -2,6 +2,14 @@ h1. sudo_attributes
2
2
 
3
3
  Adds 'sudo' methods to active record classes, allowing you to easily override protected attributes.
4
4
 
5
+ h2. Requirements
6
+
7
+ *Rails:* Any version of Rails 2.3.x or Rails 3.x. (Older versions of Rails may work, but have not been tested)
8
+
9
+ h2. Installation
10
+
11
+ The gem is hosted at "rubygems.org":https://rubygems.org/gems/sudo_attributes and can be installed with: @gem install sudo_attributes@
12
+
5
13
  h2. The Problem
6
14
 
7
15
  ActiveRecord (ActiveModel in Rails 3) provides a convenient way to make your application more secure by using "protected" attributes. Protected attributes are assigned using either @attr_protected@ or @attr_accessible@. This adds security by preventing mass assignment of attributes when doing things like @user.update_attributes(params[:user])@. The issue is that it can be tedious to always manually assign protected attributes in an administrative area of your application. You may find yourself doing things like:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
@@ -27,15 +27,12 @@ module SudoAttributes
27
27
  end
28
28
  end
29
29
 
30
- module Private
30
+ module Private # :nodoc: all
31
31
 
32
32
  # Used internally to assign protected attributes and include additional sudo_attributes functionality
33
33
  def self.set_attributes(klass, attrs, type)
34
- unless attrs.empty?
35
- raise "Invalid argument passed to has_sudo_attributes" unless attrs.all? {|a| a.is_a? Symbol }
36
-
37
- klass.send("attr_#{type}", *attrs)
38
- end
34
+ # Call attr_(accessible|protected) if attributes are passed in
35
+ klass.send("attr_#{type}", *attrs) unless attrs.empty?
39
36
 
40
37
  klass.extend SudoAttributes::ClassMethods
41
38
  klass.send :include, SudoAttributes::InstanceMethods
@@ -81,10 +78,8 @@ module SudoAttributes
81
78
  instance
82
79
  end
83
80
 
84
- # Alias of +sudo_new+
85
- def sudo_build(attributes=nil)
86
- sudo_new(attributes)
87
- end
81
+ alias sudo_build sudo_new
82
+
88
83
  end
89
84
 
90
85
  # Added to ActiveRecord model only if sudo_attr_(accessible|protected) is called
@@ -1,45 +1,43 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sudo_attributes}
8
- s.version = "0.5.1"
8
+ s.version = "0.5.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Peter Brown"]
12
- s.date = %q{2011-01-23}
12
+ s.date = %q{2011-02-19}
13
13
  s.description = %q{Adds 'sudo' methods to update protected ActiveRecord attributes with mass assignment}
14
14
  s.email = %q{github@lette.us}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.textile"
17
+ "README.textile"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "LICENSE",
25
- "README.textile",
26
- "Rakefile",
27
- "VERSION",
28
- "init.rb",
29
- "lib/sudo_attributes.rb",
30
- "spec/spec.opts",
31
- "spec/spec_helper.rb",
32
- "spec/sudo_attributes_spec.rb",
33
- "sudo_attributes.gemspec"
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE",
24
+ "README.textile",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "init.rb",
28
+ "lib/sudo_attributes.rb",
29
+ "spec/spec.opts",
30
+ "spec/spec_helper.rb",
31
+ "spec/sudo_attributes_spec.rb",
32
+ "sudo_attributes.gemspec"
34
33
  ]
35
34
  s.homepage = %q{http://github.com/beerlington/sudo_attributes}
36
- s.rdoc_options = ["--charset=UTF-8"]
37
35
  s.require_paths = ["lib"]
38
- s.rubygems_version = %q{1.4.2}
36
+ s.rubygems_version = %q{1.5.2}
39
37
  s.summary = %q{Override ActiveRecord protected attributes with mass assignment}
40
38
  s.test_files = [
41
39
  "spec/spec_helper.rb",
42
- "spec/sudo_attributes_spec.rb"
40
+ "spec/sudo_attributes_spec.rb"
43
41
  ]
44
42
 
45
43
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sudo_attributes
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 1
10
- version: 0.5.1
9
+ - 2
10
+ version: 0.5.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Peter Brown
@@ -15,12 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-23 00:00:00 -05:00
18
+ date: 2011-02-19 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rspec
23
- prerelease: false
22
+ type: :development
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
@@ -32,11 +31,11 @@ dependencies:
32
31
  - 0
33
32
  - 0
34
33
  version: 2.0.0
35
- type: :development
34
+ name: rspec
36
35
  version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: rails
39
36
  prerelease: false
37
+ - !ruby/object:Gem::Dependency
38
+ type: :development
40
39
  requirement: &id002 !ruby/object:Gem::Requirement
41
40
  none: false
42
41
  requirements:
@@ -48,11 +47,11 @@ dependencies:
48
47
  - 0
49
48
  - 0
50
49
  version: 3.0.0
51
- type: :development
50
+ name: rails
52
51
  version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: sqlite3-ruby
55
52
  prerelease: false
53
+ - !ruby/object:Gem::Dependency
54
+ type: :development
56
55
  requirement: &id003 !ruby/object:Gem::Requirement
57
56
  none: false
58
57
  requirements:
@@ -62,11 +61,11 @@ dependencies:
62
61
  segments:
63
62
  - 0
64
63
  version: "0"
65
- type: :development
64
+ name: sqlite3-ruby
66
65
  version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: rails
69
66
  prerelease: false
67
+ - !ruby/object:Gem::Dependency
68
+ type: :runtime
70
69
  requirement: &id004 !ruby/object:Gem::Requirement
71
70
  none: false
72
71
  requirements:
@@ -78,8 +77,9 @@ dependencies:
78
77
  - 3
79
78
  - 0
80
79
  version: 2.3.0
81
- type: :runtime
80
+ name: rails
82
81
  version_requirements: *id004
82
+ prerelease: false
83
83
  description: Adds 'sudo' methods to update protected ActiveRecord attributes with mass assignment
84
84
  email: github@lette.us
85
85
  executables: []
@@ -91,7 +91,6 @@ extra_rdoc_files:
91
91
  - README.textile
92
92
  files:
93
93
  - .document
94
- - .gitignore
95
94
  - Gemfile
96
95
  - Gemfile.lock
97
96
  - LICENSE
@@ -109,8 +108,8 @@ homepage: http://github.com/beerlington/sudo_attributes
109
108
  licenses: []
110
109
 
111
110
  post_install_message:
112
- rdoc_options:
113
- - --charset=UTF-8
111
+ rdoc_options: []
112
+
114
113
  require_paths:
115
114
  - lib
116
115
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -134,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
133
  requirements: []
135
134
 
136
135
  rubyforge_project:
137
- rubygems_version: 1.4.2
136
+ rubygems_version: 1.5.2
138
137
  signing_key:
139
138
  specification_version: 3
140
139
  summary: Override ActiveRecord protected attributes with mass assignment
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
22
- .bundle