discretion 3.0.0.pre.alpha → 4.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/discretion/discreet_model.rb +19 -0
- data/lib/discretion/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 467c36565f8b67d868763d6831b0d39d78a54e78aec042e0fb4d1cf532bbdf47
|
4
|
+
data.tar.gz: 5273fa43f51c2c2049f62aff8c3d4b35db6989bd16568621998a2dc383828ee5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c805308c2ddcb9c3febea8de0192585fbfa7b1d6d2d865448d2bbbca323567efb62971f46160ffbc62b5fae4895557ce68727e90038273930285144f2e5df0c9
|
7
|
+
data.tar.gz: 7e518a0b48385d43f633e42392621b5aae75786568db75253452ac633270ba9cb5f4f3bae44d96ca3d25f271b4e0e56c1eb545a9ae4ee3742bc6eef21350eebc
|
@@ -21,5 +21,24 @@ module Discretion
|
|
21
21
|
end
|
22
22
|
}, prepend: true
|
23
23
|
end
|
24
|
+
|
25
|
+
class_methods do
|
26
|
+
def discreetly_read(attribute)
|
27
|
+
attribute = attribute.to_sym
|
28
|
+
|
29
|
+
define_method(attribute) {
|
30
|
+
can_read_attr = if Discretion.currently_acting_as?(Discretion::OMNISCIENT_VIEWER) ||
|
31
|
+
Discretion.currently_acting_as?(Discretion::OMNIPOTENT_VIEWER)
|
32
|
+
true
|
33
|
+
else
|
34
|
+
yield(Discretion.current_viewer, self)
|
35
|
+
end
|
36
|
+
|
37
|
+
raise Discretion::CannotSeeError unless can_read_attr
|
38
|
+
|
39
|
+
read_attribute(attribute)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
24
43
|
end
|
25
44
|
end
|
data/lib/discretion/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discretion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abe Land
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|