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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 151384ffe6eb47722c2bba83128a44f7a724e41e105413999ef835da6078c2c6
4
- data.tar.gz: 238b0b1f5824c7d854b354c6dbea5f193fda306586fa1acec26e329271d6723b
3
+ metadata.gz: 467c36565f8b67d868763d6831b0d39d78a54e78aec042e0fb4d1cf532bbdf47
4
+ data.tar.gz: 5273fa43f51c2c2049f62aff8c3d4b35db6989bd16568621998a2dc383828ee5
5
5
  SHA512:
6
- metadata.gz: 15261a63c3ecf0d9b9b1ca501d09a09ac81d9c9a2e12e7ffdcbe65011c49007af6711c3feb8d0d8dafb1c49c1da96022e47ed226f0f69abbd57a4c06b6175ea6
7
- data.tar.gz: 9f9a15eeaaac9e9c7f108d33016dbf559b46c6bb730f7ef7d19d3b6d261ad61f19c99d738d32cd8a2d2652bfcaf6440f840ce221b4ab9ce0f5ec13392c7ee6d4
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
@@ -1,3 +1,3 @@
1
1
  module Discretion
2
- VERSION = '3.0.0.pre.alpha'.freeze
2
+ VERSION = '4.0.0.alpha'.freeze
3
3
  end
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: 3.0.0.pre.alpha
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-07-25 00:00:00.000000000 Z
11
+ date: 2018-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport