Class: Pgai::Encryption::ReferenceStore
- Inherits:
-
Object
- Object
- Pgai::Encryption::ReferenceStore
- Defined in:
- lib/pgai/encryption/reference_store.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(path: nil) ⇒ ReferenceStore
constructor
A new instance of ReferenceStore.
- #read ⇒ Object
- #write(reference) ⇒ Object
Constructor Details
#initialize(path: nil) ⇒ ReferenceStore
Returns a new instance of ReferenceStore.
6 7 8 9 |
# File 'lib/pgai/encryption/reference_store.rb', line 6 def initialize(path: nil) path ||= Pgai.config_dir.join("op_ref") @path = File.(path) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
26 27 28 |
# File 'lib/pgai/encryption/reference_store.rb', line 26 def path @path end |
Instance Method Details
#exists? ⇒ Boolean
22 23 24 |
# File 'lib/pgai/encryption/reference_store.rb', line 22 def exists? File.exist?(@path) && !read.empty? end |
#read ⇒ Object
16 17 18 19 20 |
# File 'lib/pgai/encryption/reference_store.rb', line 16 def read return nil unless File.exist?(@path) File.read(@path).strip end |
#write(reference) ⇒ Object
11 12 13 14 |
# File 'lib/pgai/encryption/reference_store.rb', line 11 def write(reference) ensure_directory_exists File.write(@path, reference) end |