protector 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf6b4587e9147a97a18ad6e3b602ca06bf59a07a
4
- data.tar.gz: 94e454726030e22b403c47d0c80869aa73c97281
3
+ metadata.gz: e15f3c1ee4395642576ca756587e32adc363b461
4
+ data.tar.gz: f18f5e9a33d866c903e7f8be1db3425daa97ad67
5
5
  SHA512:
6
- metadata.gz: 27bdf5f0e506f34c8b779ab62fc9fece5fbb0fb894230b42fc9c2da13d3d874f850ca55a377a28d6a8fec810ee0002525ceed8f3fe2168f71ffb6e807f073d77
7
- data.tar.gz: eb29c4f00148b9eea6bb980f2a57edc89acd5a6b30bba1f5ee51d81ac7cfb6fffc151e4270a120b66d6a715ec53a553830cdf95eb3f88ac474805bee68579283
6
+ metadata.gz: 61613c761e8e2193ed7d87521e1469af9fb9997f7bf0dc52f247302f179df8bbeee6f2eef3d636447d0cc250b706b819af88b2493e02e1c56b85f0a831e92eeb
7
+ data.tar.gz: 18fd32ceb5907097d297a61f73db4a2b0aa5fe306d606cd735e6796ac49fec7852758912a6745d5052e4e69f8ef864b6405c3fb9a907f78e6f81b31adac4a450
@@ -10,7 +10,7 @@ GIT
10
10
  PATH
11
11
  remote: /Users/inossidabile/Repos/protector
12
12
  specs:
13
- protector (0.3.3)
13
+ protector (0.4.1)
14
14
  activesupport
15
15
  i18n
16
16
 
@@ -6,7 +6,7 @@ GIT
6
6
  PATH
7
7
  remote: /Users/inossidabile/Repos/protector
8
8
  specs:
9
- protector (0.3.3)
9
+ protector (0.4.1)
10
10
  activesupport
11
11
  i18n
12
12
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/inossidabile/Repos/protector
3
3
  specs:
4
- protector (0.3.3)
4
+ protector (0.4.1)
5
5
  activesupport
6
6
  i18n
7
7
 
@@ -9,6 +9,7 @@ module Protector
9
9
  include Protector::DSL::Base
10
10
 
11
11
  alias_method_chain :exec_queries, :protector
12
+ alias_method_chain :new, :protector
12
13
 
13
14
  # AR 3.2 workaround. Come on, guys... SQL parsing :(
14
15
  unless method_defined?(:references_values)
@@ -73,6 +74,11 @@ module Protector
73
74
  merge(protector_meta.relation).unrestrict!.exists? *args
74
75
  end
75
76
 
77
+ def new_with_protector(*args)
78
+ return new_without_protector unless protector_subject?
79
+ new_without_protector.restrict!(protector_subject)
80
+ end
81
+
76
82
  # Patches current relation to fulfill restriction and call real `exec_queries`
77
83
  #
78
84
  # Patching includes:
@@ -1,4 +1,4 @@
1
1
  module Protector
2
2
  # Gem version
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
4
4
  end
@@ -89,6 +89,7 @@ if defined?(ActiveRecord)
89
89
  it "forwards subject" do
90
90
  Dummy.restrict!('!').where(number: 999).first.protector_subject.should == '!'
91
91
  Dummy.restrict!('!').where(number: 999).to_a.first.protector_subject.should == '!'
92
+ Dummy.restrict!('!').new.protector_subject.should == '!'
92
93
  end
93
94
 
94
95
  context "with open relation" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Staal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-11 00:00:00.000000000 Z
11
+ date: 2013-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport