accessible_for 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,10 +11,16 @@ and we don't want it stinking up the place.
11
11
  There are actually two available APIs, the ActiveModel-workalike and a new one
12
12
  called accessible_for. They provide identical functionality.
13
13
 
14
+ # Installation
15
+
16
+ $ gem install accessible_for
17
+
14
18
  # Usage
15
19
 
16
20
  ## ActiveModel-workalike API
17
21
 
22
+ require 'mass_assignment_backport'
23
+
18
24
  class TacoShop < Controller
19
25
  include MassAssignmentBackport
20
26
 
@@ -42,6 +48,8 @@ called accessible_for. They provide identical functionality.
42
48
 
43
49
  ## accessible_for API
44
50
 
51
+ require 'accessible_for'
52
+
45
53
  class TacoShop < Controller
46
54
  include AccessibleFor
47
55
 
@@ -1,7 +1,7 @@
1
1
  require 'mass_assignment_backport'
2
2
 
3
3
  module AccessibleFor
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
 
6
6
  def self.included(mod)
7
7
  mod.send :include, MassAssignmentBackport
@@ -1,6 +1,4 @@
1
1
  module MassAssignmentBackport
2
- VERSION = "0.1.0"
3
-
4
2
  def self.included(mod)
5
3
  mod.extend ClassMethods
6
4
  end
@@ -23,6 +21,7 @@ module MassAssignmentBackport
23
21
  end
24
22
 
25
23
  def sanitize_for_mass_assignment values, role=:default
24
+ return {} if values.nil?
26
25
  {}.tap do |result|
27
26
  values.each do |k, v|
28
27
  if self.class._accessible_attributes[role].include?(k.to_sym)
@@ -5,6 +5,9 @@ class MassAssignmentTest < MiniTest::Unit::TestCase
5
5
  attr_accessible :topping, :as => [:default, :manager]
6
6
  attr_accessible :price, :as => :manager
7
7
 
8
+ def test_nil_params
9
+ assert_empty sanitize_for_mass_assignment(nil)
10
+ end
8
11
  def test_accessible_default
9
12
  default = sanitize_for_mass_assignment :topping => 'salsa', :price => 123, :extra => 'foo'
10
13
  assert default.has_key?(:topping), "default gets accessible key"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: accessible_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
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: 2012-03-06 00:00:00.000000000Z
12
+ date: 2012-03-07 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: ! " This is a simple mass-assignment security module loosely based
15
15
  on\n ActiveModel::MassAssignmentSecurity. It attempts to steal the good ideas\n
@@ -24,7 +24,6 @@ files:
24
24
  - accessible_for.gemspec
25
25
  - lib/accessible_for.rb
26
26
  - lib/mass_assignment_backport.rb
27
- - mass_assignment_backport.gemspec
28
27
  - test/accessible_for_test.rb
29
28
  - test/mass_assignment_test.rb
30
29
  homepage:
@@ -1,16 +0,0 @@
1
- $:.unshift File.expand_path("./lib")
2
- require 'mass_assignment_backport'
3
-
4
- Gem::Specification.new do |s|
5
- s.name = "mass_assignment_backport"
6
- s.version = MassAssignmentBackport::VERSION
7
- s.summary = 'Simple API for sanitizing hashes by input key'
8
- s.description = <<-EOD
9
- This is a simple mass-assignment security module loosely based on
10
- ActiveModel::MassAssignmentSecurity. It attempts to steal the good ideas
11
- and some of the API while being compatible with Rails 2.3-based applications.
12
- EOD
13
- s.authors = ['Zack Hobson']
14
- s.files = `git ls-files`.split("\n")
15
- s.test_files = `git ls-files -- test/*`.split("\n")
16
- end