safe_attributes 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -62,6 +62,11 @@ without issue using the recommended approach above.
62
62
 
63
63
  == Using
64
64
 
65
+ === Ruby
66
+
67
+ Both Ruby 1.8.7 and Ruby 1.9.2 have been tested to work with this gem as
68
+ of version 1.0.4 of SafeAttributes.
69
+
65
70
  === Rails
66
71
  Add safe_attributes to your Gemfile.
67
72
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 1.0.4
@@ -12,11 +12,11 @@ module SafeAttributes
12
12
  #
13
13
  def bad_attribute_names(*attrs)
14
14
  @bad_attribute_names ||= lambda {
15
- methods = Array.new(attrs.collect { |x| x.to_s })
16
- methods += ActiveRecord::Base.public_instance_methods
17
- methods += ActiveRecord::Base.protected_instance_methods
18
- methods += ActiveRecord::Base.private_instance_methods
19
- methods -= ['id']
15
+ methods = Array.new(attrs.collect { |x| x.to_sym })
16
+ methods += ActiveRecord::Base.public_instance_methods.collect { |x| x.to_sym }
17
+ methods += ActiveRecord::Base.protected_instance_methods.collect { |x| x.to_sym }
18
+ methods += ActiveRecord::Base.private_instance_methods.collect { |x| x.to_sym }
19
+ methods -= [:id]
20
20
  return methods
21
21
  }.call
22
22
  end
@@ -27,7 +27,7 @@ module SafeAttributes
27
27
  # bad names
28
28
  #
29
29
  def define_method_attribute(attr_name)
30
- return if (bad_attribute_names.include?(attr_name))
30
+ return if (bad_attribute_names.include?(attr_name.to_sym))
31
31
  super(attr_name)
32
32
  end
33
33
 
@@ -38,7 +38,7 @@ module SafeAttributes
38
38
  #
39
39
  def define_method_attribute=(attr_name)
40
40
  method = attr_name + '='
41
- return if (bad_attribute_names.include?(method))
41
+ return if (bad_attribute_names.include?(method.to_sym))
42
42
  super(attr_name)
43
43
  end
44
44
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{safe_attributes}
8
- s.version = "1.0.3"
8
+ s.version = "1.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian Jones"]
12
- s.date = %q{2011-02-01}
12
+ s.date = %q{2011-02-04}
13
13
  s.description = %q{Better support for legacy database schemas for ActiveRecord, such as columns named class, or any other name that conflicts with an instance method of ActiveRecord.}
14
14
  s.email = %q{cbj@gnu.org}
15
15
  s.extra_rdoc_files = [
@@ -40,33 +40,33 @@ describe MyModel do
40
40
  end
41
41
 
42
42
  it "defines class=()" do
43
- @model.respond_to?('class=') # to force method generation
44
- @model.methods.include?('class=').should be_true
43
+ @model.respond_to?(:class=) # to force method generation
44
+ (@model.methods.include?('class=') || @model.methods.include?(:class=)).should be_true
45
45
  end
46
46
 
47
47
  it "does not define bad_attribute()" do
48
- @model.respond_to?('bad_attribute') # to force method generation
49
- @model.methods.include?('bad_attribute').should be_false
48
+ @model.respond_to?(:bad_attribute) # to force method generation
49
+ (@model.methods.include?('bad_attribute') || @model.methods.include?(:bad_attribute)).should be_false
50
50
  end
51
51
 
52
52
  it "does not define bad_attribute=()" do
53
- @model.respond_to?('bad_attribute=') # to force method generation
54
- @model.methods.include?('bad_attribute=').should be_false
53
+ @model.respond_to?(:bad_attribute=) # to force method generation
54
+ (@model.methods.include?('bad_attribute=') || @model.methods.include?(:bad_attribute=)).should be_false
55
55
  end
56
56
 
57
57
  it "does define good_attribute()" do
58
- @model.respond_to?('good_attribute') # to force method generation
59
- @model.methods.include?('good_attribute').should be_true
58
+ @model.respond_to?(:good_attribute) # to force method generation
59
+ (@model.methods.include?('good_attribute') || @model.methods.include?(:good_attribute)).should be_true
60
60
  end
61
61
 
62
62
  it "does define good_attribute=()" do
63
- @model.respond_to?('good_attribute=') # to force method generation
64
- @model.methods.include?('good_attribute=').should be_true
63
+ @model.respond_to?(:good_attribute=) # to force method generation
64
+ (@model.methods.include?('good_attribute=') || @model.methods.include?(:good_attribute=)).should be_true
65
65
  end
66
66
 
67
67
  it "does define id()" do
68
- @model.respond_to?('id') # to force method generation
69
- @model.methods.include?('id').should be_true
68
+ @model.respond_to?(:id) # to force method generation
69
+ (@model.methods.include?('id') || @model.methods.include?(:id)).should be_true
70
70
  end
71
71
 
72
72
  it "can create instance in database with special attribute name" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safe_attributes
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 3
10
- version: 1.0.3
9
+ - 4
10
+ version: 1.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Jones
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-01 00:00:00 -05:00
18
+ date: 2011-02-04 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency