whiny-mass-assignment 0.1.9 → 0.2.0

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.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new( 'whiny-mass-assignment', '0.1.9', ) do |p|
5
+ Echoe.new( 'whiny-mass-assignment', '0.2.0', ) do |p|
6
6
  p.description = "Complain loudly when protected attributes are set through mass assignment."
7
7
  p.url = "https://github.com/appsinyourpants/whiny-mass-assignment"
8
8
  p.author = "Paul Alexander"
@@ -15,11 +15,11 @@ module WhinyMassAssignment
15
15
  @mode = value
16
16
  end
17
17
 
18
- def whitelist
18
+ def self.whitelist
19
19
  @whitelist ||= { :mode => :raise, :except => [] }
20
20
  end
21
21
 
22
- def whitelist=( options = {} )
22
+ def self.whitelist=( options = {} )
23
23
  options[:mode] ||= :raise
24
24
  @whitelist = options
25
25
  end
@@ -4,26 +4,25 @@ module ActiveModel
4
4
  module MassAssignmentSecurity
5
5
 
6
6
 
7
- def sanitize_for_mass_assignment_with_warning(attributes,&block)
8
- sanitize_for_mass_assignment_without_warning(attributes,&block).tap{
9
- return unless Config.whitelist[:mode] == :none
10
- warn_when_mass_assignment_is_not_whitelist unless mass_assignment_authorizer === WhiteList
11
- }
7
+ def sanitize_for_mass_assignment_with_warning(attributes)
8
+ warn_when_mass_assignment_is_not_whitelist unless mass_assignment_authorizer === WhiteList
9
+ sanitize_for_mass_assignment_without_warning(attributes)
12
10
  end
13
11
  alias_method_chain :sanitize_for_mass_assignment, :warning
14
12
 
15
13
 
16
14
  def warn_when_mass_assignment_is_not_whitelist
17
- only = Config.whitelist[:only]
15
+ return if WhinyMassAssignment::Config.whitelist[:mode] == :none
16
+ only = WhinyMassAssignment::Config.whitelist[:only]
18
17
  if only
19
18
  return unless only.include?( self.class )
20
19
  else
21
- except = Config.whitelist[:except]
20
+ except = WhinyMassAssignment::Config.whitelist[:except]
22
21
  return if except && except.include?( self.class )
23
22
  end
24
23
 
25
- self.logger.debug WhinyMassAssignment::bc :yellow, "Mass assignment whitelisting has not been specified for #{ c [:bright, :red], self.class.name }" if self.logger
26
- raise "Can't mass-assign protected attributes: #{attrs.join(', ')}" if Config.whitelist[:mode] == :raise
24
+ self.logger.debug WhinyMassAssignment::bc :yellow, "Mass assignment whitelisting has not been specified for #{ WhinyMassAssignment::c [:bright, :red], self.class.name }" if self.logger
25
+ raise "Mass assignment whitelisting has not been specified for `#{self.class.name}`." if WhinyMassAssignment::Config.whitelist[:mode] == :raise
27
26
  end
28
27
 
29
28
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{whiny-mass-assignment}
5
- s.version = "0.1.9"
5
+ s.version = "0.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Paul Alexander"]
9
- s.date = %q{2011-03-18}
9
+ s.date = %q{2011-03-19}
10
10
  s.description = %q{Complain loudly when protected attributes are set through mass assignment.}
11
11
  s.email = %q{paul@appsinyourpants.com}
12
12
  s.extra_rdoc_files = ["LICENSE", "README.md", "lib/whiny-mass-assignment.rb", "lib/whiny-mass-assignment/color_escapes.rb", "lib/whiny-mass-assignment/configuration.rb", "lib/whiny-mass-assignment/mass_assignment_security_overrides.rb", "lib/whiny-mass-assignment/sanitizer.rb", "lib/whiny_mass_assignment.rb", "tasks/spec.rake"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whiny-mass-assignment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-03-18 00:00:00.000000000 -07:00
12
+ date: 2011-03-19 00:00:00.000000000 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
  description: Complain loudly when protected attributes are set through mass assignment.