Module: Hydra::AccessControls::Visibility::InstanceMethods
- Defined in:
- app/models/concerns/hydra/access_controls/visibility.rb
Instance Method Summary collapse
-
#attributes ⇒ Object
Overridden for ActiveModel::Dirty tracking of visibility Required by ActiveModel::AttributeMethods An instance variable is used to avoid infinite recursion caused by calling #visibility Using this approach requires setting visibility read groups through #visibility= instead of manipulating them directly if #visibility_changed? is expected to work correctly.
- #visibility ⇒ Object
- #visibility=(value) ⇒ Object
Instance Method Details
#attributes ⇒ Object
Overridden for ActiveModel::Dirty tracking of visibility Required by ActiveModel::AttributeMethods An instance variable is used to avoid infinite recursion caused by calling #visibility Using this approach requires setting visibility read groups through #visibility= instead of manipulating them directly if #visibility_changed? is expected to work correctly.
50 51 52 |
# File 'app/models/concerns/hydra/access_controls/visibility.rb', line 50 def attributes super.merge({ 'visibility' => @visibility }) end |
#visibility ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'app/models/concerns/hydra/access_controls/visibility.rb', line 34 def visibility if read_groups.include? AccessRight::PERMISSION_TEXT_VALUE_PUBLIC AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC elsif read_groups.include? AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED else AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE end end |
#visibility=(value) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/concerns/hydra/access_controls/visibility.rb', line 18 def visibility=(value) return if value.nil? # only set explicit permissions case value when AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC public_visibility! when AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED registered_visibility! when AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE private_visibility! else raise ArgumentError, "Invalid visibility: #{value.inspect}" end @visibility = value end |