Class: Squads
- Inherits:
-
Object
- Object
- Squads
- Defined in:
- lib/terraorg/model/squads.rb
Constant Summary collapse
- SCHEMA_VERSION =
'v1'.freeze
Instance Method Summary collapse
- #all ⇒ Object
- #all_names ⇒ Object
-
#initialize(parsed_data, people, gsuite_domain, slack_domain) ⇒ Squads
constructor
A new instance of Squads.
- #lookup!(name) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(parsed_data, people, gsuite_domain, slack_domain) ⇒ Squads
Returns a new instance of Squads.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/terraorg/model/squads.rb', line 20 def initialize(parsed_data, people, gsuite_domain, slack_domain) version = parsed_data.fetch('version') raise "Unsupported squads schema version: #{version}" if version != SCHEMA_VERSION @squads = {} parsed_data.fetch('squads').each do |squad| id = squad.fetch('id') @squads[id] = Squad.new(id, squad, people, gsuite_domain, slack_domain) end end |
Instance Method Details
#all ⇒ Object
31 32 33 |
# File 'lib/terraorg/model/squads.rb', line 31 def all @squads.values end |
#all_names ⇒ Object
35 36 37 |
# File 'lib/terraorg/model/squads.rb', line 35 def all_names @squads.keys end |
#lookup!(name) ⇒ Object
39 40 41 |
# File 'lib/terraorg/model/squads.rb', line 39 def lookup!(name) @squads.fetch(name) end |
#to_h ⇒ Object
43 44 45 |
# File 'lib/terraorg/model/squads.rb', line 43 def to_h { 'version' => SCHEMA_VERSION, 'squads' => @squads.values.sort_by(&:id).map(&:to_h) } end |