Class: Folder
- Inherits:
-
Object
- Object
- Folder
- Defined in:
- lib/models/folder.rb
Instance Attribute Summary collapse
-
#encryptables ⇒ Object
readonly
Returns the value of attribute encryptables.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name: nil, id: nil, encryptables: []) ⇒ Folder
constructor
A new instance of Folder.
Constructor Details
#initialize(name: nil, id: nil, encryptables: []) ⇒ Folder
Returns a new instance of Folder.
6 7 8 9 10 |
# File 'lib/models/folder.rb', line 6 def initialize(name: nil, id: nil, encryptables: []) @name = name @id = id @encryptables = encryptables end |
Instance Attribute Details
#encryptables ⇒ Object (readonly)
Returns the value of attribute encryptables.
4 5 6 |
# File 'lib/models/folder.rb', line 4 def encryptables @encryptables end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/models/folder.rb', line 4 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/models/folder.rb', line 4 def name @name end |
Class Method Details
.find(id) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/models/folder.rb', line 13 def find(id) json = JSON.parse(CryptopusAdapter.new.get("folders/#{id}"), symbolize_names: true) included = json[:included] || [] name = json[:data][:attributes][:name] encryptables = included.map do |record| Encryptable.from_json(record.to_json) if %w[encryptable_ose_secrets encryptable_credentials].include? record[:type] end.compact Folder.new(id: id, name: name, encryptables: encryptables) end |