discretion 1.0.0.pre.alpha → 2.0.0.pre.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
  SHA1:
3
- metadata.gz: a56b9cc6109e4904c4c4ffa1569af797b4e043a7
4
- data.tar.gz: 77a3f57cd1628eee0ed41ca2ae4c71f032309829
3
+ metadata.gz: 356b1ea298c592e14cc0bee26238faf978a325da
4
+ data.tar.gz: 68ea3e321eb97c0c718c7ce28e11d6f92cf6f3e2
5
5
  SHA512:
6
- metadata.gz: 2ec9587ef19c98cd89b9ed107c16907a9a7c3fe1316f58b86b6ac66e38c4bef621c959e1286d2f04466e6b4dea1168e12a8e20959b8b33a5395eaa9816c2bd7a
7
- data.tar.gz: e3b5fcad23ef87209535356e5ea6d5c4c9d2bc3d60d4cc722c1a772ab05e92a420a6d4cb74fc2d87adcca341b44d61b80d44e2b13fa3db736d3b85ef88f89c01
6
+ metadata.gz: ea101402106c86b157f4741bdba29563b33d8d07620bc88b5e4031972dd92cb426134be70e14b40ddf7ecb274f015697ee71ee7cf8c1098e3f1dad882d729705
7
+ data.tar.gz: '058fa5ae16167fab16beb478f630d3a7c7e0a9d8a9fd6d22cf81da1c5a1218e86c3863dae2196360c775f4ca5755311dd65da545deb5569cdbb48e30461c50f4'
@@ -8,8 +8,15 @@ module Discretion
8
8
  Rails.env.test?
9
9
  end
10
10
 
11
- def can_see_records?(viewer, *records)
12
- records.all? { |record| Discretion.can_see_record?(viewer, record) }
11
+ def try_to(viewer)
12
+ orig_viewer = Discretion.current_viewer
13
+ Discretion.set_current_viewer(viewer)
14
+ yield
15
+ true
16
+ rescue Discretion::CannotSeeError, Discretion::CannotWriteError
17
+ false
18
+ ensure
19
+ Discretion.set_current_viewer(orig_viewer)
13
20
  end
14
21
 
15
22
  def omnisciently
@@ -1,3 +1,3 @@
1
1
  module Discretion
2
- VERSION = '1.0.0.pre.alpha'.freeze
2
+ VERSION = '2.0.0.pre.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: 1.0.0.pre.alpha
4
+ version: 2.0.0.pre.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-02-02 00:00:00.000000000 Z
11
+ date: 2018-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport