Class: Uniword::Protect::Manager
- Inherits:
-
Object
- Object
- Uniword::Protect::Manager
- Defined in:
- lib/uniword/protect/manager.rb
Overview
Manages document protection settings.
Provides operations for setting editing restrictions and password protection on documents.
Protection types:
-
:read_only — no edits allowed
-
:comments — only comments allowed
-
:tracked_changes — only tracked changes allowed
-
:forms — only form fields editable
Constant Summary collapse
- PROTECTION_TYPES =
%i[ read_only comments tracked_changes forms ].freeze
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
-
#apply(protection_type, password: nil) ⇒ void
Apply editing restriction to the document.
-
#info ⇒ Hash?
Get current protection info.
-
#initialize(document) ⇒ Manager
constructor
Initialize with a document.
-
#protected? ⇒ Boolean
Check if the document is protected.
-
#remove ⇒ void
Remove all protection from the document.
Constructor Details
#initialize(document) ⇒ Manager
Initialize with a document.
35 36 37 38 |
# File 'lib/uniword/protect/manager.rb', line 35 def initialize(document) @document = document @protection = nil end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
30 31 32 |
# File 'lib/uniword/protect/manager.rb', line 30 def document @document end |
Instance Method Details
#apply(protection_type, password: nil) ⇒ void
This method returns an undefined value.
Apply editing restriction to the document.
46 47 48 49 50 |
# File 'lib/uniword/protect/manager.rb', line 46 def apply(protection_type, password: nil) validate_type(protection_type) @protection = build_protection(protection_type, password) end |
#info ⇒ Hash?
Get current protection info.
69 70 71 72 73 74 75 76 |
# File 'lib/uniword/protect/manager.rb', line 69 def info return nil unless @protection { type: protection_type(@protection), password_protected: password_protected?(@protection), } end |
#protected? ⇒ Boolean
Check if the document is protected.
62 63 64 |
# File 'lib/uniword/protect/manager.rb', line 62 def protected? !@protection.nil? end |
#remove ⇒ void
This method returns an undefined value.
Remove all protection from the document.
55 56 57 |
# File 'lib/uniword/protect/manager.rb', line 55 def remove @protection = nil end |