Class: Nvoi::External::Database::Types::BranchMetadata
- Inherits:
-
Object
- Object
- Nvoi::External::Database::Types::BranchMetadata
- Defined in:
- lib/nvoi/external/database/types.rb
Overview
BranchMetadata holds all branches for an app
Instance Attribute Summary collapse
-
#branches ⇒ Object
Returns the value of attribute branches.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(branches = []) ⇒ BranchMetadata
constructor
A new instance of BranchMetadata.
- #to_json(*_args) ⇒ Object
Constructor Details
#initialize(branches = []) ⇒ BranchMetadata
Returns a new instance of BranchMetadata.
30 31 32 |
# File 'lib/nvoi/external/database/types.rb', line 30 def initialize(branches = []) @branches = branches end |
Instance Attribute Details
#branches ⇒ Object
Returns the value of attribute branches.
28 29 30 |
# File 'lib/nvoi/external/database/types.rb', line 28 def branches @branches end |
Class Method Details
.from_json(json_str) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/nvoi/external/database/types.rb', line 38 def self.from_json(json_str) data = JSON.parse(json_str) branches = (data["branches"] || []).map do |b| Branch.new( id: b["id"], created_at: b["created_at"], size: b["size"], adapter: b["adapter"], database: b["database"] ) end new(branches) end |
Instance Method Details
#to_json(*_args) ⇒ Object
34 35 36 |
# File 'lib/nvoi/external/database/types.rb', line 34 def to_json(*_args) JSON.pretty_generate({ branches: @branches.map(&:to_h) }) end |