protector 0.5.5 → 0.6.0.beta.1
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8246af354a37e155b5bfbcb3df55fb001b10d3a4
|
4
|
+
data.tar.gz: c0d84e8e3ab4a909a693397a420bbd60ede12e2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d4ce7f662b483d145d390082f6457168b1c2823fce888c09393d0dfd942a15c72ed0efe231393544949ff92f12b6550262c6378d65af96a0d858ac32f5f48b4
|
7
|
+
data.tar.gz: 773f20d60bbbd7f62e6023fcff64aa686b1f4706a5c5716575559a3b0778b304e9ba277eb3df350ce6c8fb889f3cfe20c514cc6cddadfbeccc20225e996ff122
|
@@ -130,7 +130,7 @@ module Protector
|
|
130
130
|
unscoped.protector_mimic_base!
|
131
131
|
|
132
132
|
# Finally we merge unscoped basic relation extended with protection scope
|
133
|
-
relation = relation.merge
|
133
|
+
relation = relation.merge meta.eval_scope_procs(unscoped)
|
134
134
|
end
|
135
135
|
end
|
136
136
|
else
|
@@ -40,7 +40,7 @@ module Protector
|
|
40
40
|
return each_without_protector(*args, &block) unless protector_subject?
|
41
41
|
|
42
42
|
relation = protector_defend_graph(clone, protector_subject)
|
43
|
-
relation =
|
43
|
+
relation = protector_meta.eval_scope_procs(relation) if protector_meta.scoped?
|
44
44
|
|
45
45
|
relation.row_proc = Restrictor.new(protector_subject, relation.row_proc)
|
46
46
|
relation.each_without_protector(*args, &block)
|
@@ -55,7 +55,7 @@ module Protector
|
|
55
55
|
model = reflection[:class_name].constantize unless model
|
56
56
|
meta = model.protector_meta.evaluate(subject)
|
57
57
|
|
58
|
-
relation =
|
58
|
+
relation = meta.eval_scope_procs(relation) if meta.scoped?
|
59
59
|
end
|
60
60
|
|
61
61
|
relation
|
data/lib/protector/dsl.rb
CHANGED
@@ -17,7 +17,7 @@ module Protector
|
|
17
17
|
@model = model
|
18
18
|
@fields = fields
|
19
19
|
@access = {update: {}, view: {}, create: {}}
|
20
|
-
@
|
20
|
+
@scope_procs = []
|
21
21
|
@destroyable = false
|
22
22
|
|
23
23
|
Protector.insecurely do
|
@@ -37,7 +37,7 @@ module Protector
|
|
37
37
|
# Checks whether protection with given subject
|
38
38
|
# has the selection scope defined
|
39
39
|
def scoped?
|
40
|
-
Protector.config.paranoid? ||
|
40
|
+
Protector.config.paranoid? || @scope_procs.length > 0
|
41
41
|
end
|
42
42
|
|
43
43
|
# @group Protection DSL
|
@@ -53,25 +53,25 @@ module Protector
|
|
53
53
|
# scope { none }
|
54
54
|
# end
|
55
55
|
def scope(&block)
|
56
|
-
@
|
57
|
-
|
58
|
-
@relation = false
|
59
|
-
@unscoped_relation = false
|
56
|
+
@scope_procs << block
|
57
|
+
@relation = false
|
60
58
|
end
|
61
59
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
65
|
-
else
|
66
|
-
@scope_proc || @adapter.null_proc
|
67
|
-
end
|
60
|
+
def scope_procs
|
61
|
+
return [@adapter.null_proc] if @scope_procs.empty? && Protector.config.paranoid?
|
62
|
+
@scope_procs
|
68
63
|
end
|
69
64
|
|
70
65
|
def relation
|
71
66
|
return false unless scoped?
|
72
67
|
|
73
|
-
@relation ||= @model
|
74
|
-
|
68
|
+
@relation ||= eval_scope_procs @model
|
69
|
+
end
|
70
|
+
|
71
|
+
def eval_scope_procs(instance)
|
72
|
+
return scope_procs.reduce(instance) do |relation, scope_proc|
|
73
|
+
relation.instance_eval(&scope_proc)
|
74
|
+
end
|
75
75
|
end
|
76
76
|
|
77
77
|
# Enables action for given fields.
|
data/lib/protector/version.rb
CHANGED
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
|
+
version: 0.6.0.beta.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-08-
|
11
|
+
date: 2013-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -102,9 +102,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
102
|
version: '0'
|
103
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
|
-
- - '
|
105
|
+
- - '>'
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
107
|
+
version: 1.3.1
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
110
|
rubygems_version: 2.0.6
|