Class: Folder
- Inherits:
-
Object
- Object
- Folder
- Defined in:
- lib/models/folder.rb
Instance Attribute Summary collapse
-
#accounts ⇒ Object
readonly
Returns the value of attribute accounts.
-
#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, accounts: []) ⇒ Folder
constructor
A new instance of Folder.
Constructor Details
#initialize(name: nil, id: nil, accounts: []) ⇒ 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, accounts: []) @name = name @id = id @accounts = accounts end |
Instance Attribute Details
#accounts ⇒ Object (readonly)
Returns the value of attribute accounts.
4 5 6 |
# File 'lib/models/folder.rb', line 4 def accounts @accounts 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] accounts = included.map do |record| Account.from_json(record.to_json) if %w[account_ose_secrets account_credentials].include? record[:type] end.compact Folder.new(id: id, name: name, accounts: accounts) end |