hydra-access-controls 12.1.0 → 13.0.0

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: d746a886953c496a8dc25145ca468473f24988db6d2aeabe191b3001a7570b3e
4
- data.tar.gz: 2b3d9f45bef0f184f735c16cfeb5ca8155ca5f6328d9e241c0065375d732b2f2
3
+ metadata.gz: 5ff7d89f80e476ffc0fb19c5149d560b680c1ab197a43a21dc240f4368c029a0
4
+ data.tar.gz: 41c6476c6f4f56ac92b4572d3c6c698e667c9802bcd11bed90b28d2f80b10a6d
5
5
  SHA512:
6
- metadata.gz: 476fc32fd3f1b0accceb8e5c67f14a15d057dc3be62ca483af84b0174f068e68a282dcab5ecdfa9854130650b9ab2743ce30bb53a71c037cb907ad7aab5a38c5
7
- data.tar.gz: 6340762ebeb31c19aeb67d185a0da530f0b57394bb7e982a9f19f2cd1c24fd1402df769b1ef1c1c2690b8c3458679ee9b6dafe9074a61efff471e3a90923be09
6
+ metadata.gz: d1c18d26af1a1cdbac16fb34bc0bd38b2a56d6599b3a4a5e5447a19b374a2aaac779b10d13f09aae9da17c14bc633e13b3f79e0161ac10fa43808c03f7aa0e16
7
+ data.tar.gz: 328e34ff6d1429bf05c116717794df6acd8bb1d5e43bdc41f190fc231ade9f162fd0fd87a2e469f9664d12f2be45bbb9a2d2de1b9602fc2af46135b197c1e464
@@ -8,69 +8,75 @@ module Hydra::AccessControls
8
8
  define_attribute_methods :visibility
9
9
  # instance variable needs to be initialized here based upon what is in read_groups
10
10
  after_initialize { @visibility = visibility }
11
+ # Starting in Rails 7.2, define_attribute_methods creates a module that overrides accessor methods
12
+ # defined in this module. In order for the methods in this module to take precedence over those
13
+ # they need to be defined in a submodule and included after running define_attribute_methods.
14
+ include InstanceMethods
11
15
  end
12
16
 
13
- def visibility=(value)
14
- return if value.nil?
15
- # only set explicit permissions
16
- case value
17
- when AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
18
- public_visibility!
19
- when AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
20
- registered_visibility!
21
- when AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
22
- private_visibility!
23
- else
24
- raise ArgumentError, "Invalid visibility: #{value.inspect}"
17
+ module InstanceMethods
18
+ def visibility=(value)
19
+ return if value.nil?
20
+ # only set explicit permissions
21
+ case value
22
+ when AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
23
+ public_visibility!
24
+ when AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
25
+ registered_visibility!
26
+ when AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
27
+ private_visibility!
28
+ else
29
+ raise ArgumentError, "Invalid visibility: #{value.inspect}"
30
+ end
31
+ @visibility = value
25
32
  end
26
- @visibility = value
27
- end
28
33
 
29
- def visibility
30
- if read_groups.include? AccessRight::PERMISSION_TEXT_VALUE_PUBLIC
31
- AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
32
- elsif read_groups.include? AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED
33
- AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
34
- else
35
- AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
34
+ def visibility
35
+ if read_groups.include? AccessRight::PERMISSION_TEXT_VALUE_PUBLIC
36
+ AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
37
+ elsif read_groups.include? AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED
38
+ AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
39
+ else
40
+ AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
41
+ end
36
42
  end
37
- end
38
43
 
39
- # Overridden for ActiveModel::Dirty tracking of visibility
40
- # Required by ActiveModel::AttributeMethods
41
- # @see https://api.rubyonrails.org/classes/ActiveModel/AttributeMethods.html
42
- # An instance variable is used to avoid infinite recursion caused by calling #visibility
43
- # Using this approach requires setting visibility read groups through #visibility=
44
- # instead of manipulating them directly if #visibility_changed? is expected to work correctly.
45
- def attributes
46
- super.merge({ 'visibility' => @visibility })
47
- end
44
+ # Overridden for ActiveModel::Dirty tracking of visibility
45
+ # Required by ActiveModel::AttributeMethods
46
+ # @see https://api.rubyonrails.org/classes/ActiveModel/AttributeMethods.html
47
+ # An instance variable is used to avoid infinite recursion caused by calling #visibility
48
+ # Using this approach requires setting visibility read groups through #visibility=
49
+ # instead of manipulating them directly if #visibility_changed? is expected to work correctly.
50
+ def attributes
51
+ super.merge({ 'visibility' => @visibility })
52
+ end
48
53
 
49
- private
54
+ private
50
55
 
51
- # Override represented_visibility if you want to add another visibility that is
52
- # represented as a read group (e.g. on-campus)
53
- # @return [Array] a list of visibility types that are represented as read groups
54
- def represented_visibility
55
- [AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED,
56
- AccessRight::PERMISSION_TEXT_VALUE_PUBLIC]
57
- end
56
+ # Override represented_visibility if you want to add another visibility that is
57
+ # represented as a read group (e.g. on-campus)
58
+ # @return [Array] a list of visibility types that are represented as read groups
59
+ def represented_visibility
60
+ [AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED,
61
+ AccessRight::PERMISSION_TEXT_VALUE_PUBLIC]
62
+ end
58
63
 
59
- def public_visibility!
60
- visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
61
- remove_groups = represented_visibility - [AccessRight::PERMISSION_TEXT_VALUE_PUBLIC]
62
- set_read_groups([AccessRight::PERMISSION_TEXT_VALUE_PUBLIC], remove_groups)
63
- end
64
+ def public_visibility!
65
+ visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
66
+ remove_groups = represented_visibility - [AccessRight::PERMISSION_TEXT_VALUE_PUBLIC]
67
+ set_read_groups([AccessRight::PERMISSION_TEXT_VALUE_PUBLIC], remove_groups)
68
+ end
64
69
 
65
- def registered_visibility!
66
- visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
67
- remove_groups = represented_visibility - [AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED]
68
- set_read_groups([AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED], remove_groups)
69
- end
70
+ def registered_visibility!
71
+ visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
72
+ remove_groups = represented_visibility - [AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED]
73
+ set_read_groups([AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED], remove_groups)
74
+ end
70
75
 
71
- def private_visibility!
72
- visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
73
- set_read_groups([], represented_visibility)
74
- end
76
+ def private_visibility!
77
+ visibility_will_change! unless visibility == AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
78
+ set_read_groups([], represented_visibility)
79
+ end
80
+ end
75
81
  end
76
82
  end
@@ -17,9 +17,9 @@ Gem::Specification.new do |gem|
17
17
  gem.license = "APACHE-2.0"
18
18
  gem.metadata = { "rubygems_mfa_required" => "true" }
19
19
 
20
- gem.required_ruby_version = '>= 2.4'
20
+ gem.required_ruby_version = '>= 3.1'
21
21
 
22
- gem.add_dependency 'activesupport', '>= 5.2', '< 7.1'
22
+ gem.add_dependency 'activesupport', '>= 6.1', '< 8.0'
23
23
  gem.add_dependency 'active-fedora', '>= 10.0.0'
24
24
  gem.add_dependency 'blacklight-access_controls', '~> 6.0'
25
25
  gem.add_dependency 'cancancan', '>= 1.8', '< 4'
@@ -7,7 +7,6 @@ require 'blacklight-access_controls'
7
7
 
8
8
  module Hydra
9
9
  extend ActiveSupport::Autoload
10
- autoload :AccessControls
11
10
  autoload :User
12
11
  autoload :AccessControlsEnforcement
13
12
  autoload :PolicyAwareAccessControlsEnforcement
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-access-controls
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.1.0
4
+ version: 13.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-01-27 00:00:00.000000000 Z
13
+ date: 2024-10-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -18,20 +18,20 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '5.2'
21
+ version: '6.1'
22
22
  - - "<"
23
23
  - !ruby/object:Gem::Version
24
- version: '7.1'
24
+ version: '8.0'
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
28
28
  requirements:
29
29
  - - ">="
30
30
  - !ruby/object:Gem::Version
31
- version: '5.2'
31
+ version: '6.1'
32
32
  - - "<"
33
33
  - !ruby/object:Gem::Version
34
- version: '7.1'
34
+ version: '8.0'
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: active-fedora
37
37
  requirement: !ruby/object:Gem::Requirement
@@ -135,7 +135,6 @@ files:
135
135
  - app/indexers/hydra/access_controls/embargo_indexer.rb
136
136
  - app/indexers/hydra/access_controls/lease_indexer.rb
137
137
  - app/models/ability.rb
138
- - app/models/concerns/hydra/access_controls.rb
139
138
  - app/models/concerns/hydra/access_controls/access_right.rb
140
139
  - app/models/concerns/hydra/access_controls/embargoable.rb
141
140
  - app/models/concerns/hydra/access_controls/permissions.rb
@@ -217,14 +216,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
216
  requirements:
218
217
  - - ">="
219
218
  - !ruby/object:Gem::Version
220
- version: '2.4'
219
+ version: '3.1'
221
220
  required_rubygems_version: !ruby/object:Gem::Requirement
222
221
  requirements:
223
222
  - - ">="
224
223
  - !ruby/object:Gem::Version
225
224
  version: '0'
226
225
  requirements: []
227
- rubygems_version: 3.3.26
226
+ rubygems_version: 3.4.1
228
227
  signing_key:
229
228
  specification_version: 4
230
229
  summary: Access controls for project hydra
@@ -1,10 +0,0 @@
1
- module Hydra
2
- module AccessControls
3
- extend ActiveSupport::Autoload
4
- autoload :AccessRight
5
- autoload :WithAccessRight
6
- autoload :Embargoable
7
- autoload :Visibility
8
- autoload :Permissions
9
- end
10
- end