Class: Teems::Commands::OrgRenderer::OrgData

Inherits:
Struct
  • Object
show all
Defined in:
lib/teems/commands/org.rb

Overview

Groups org chart data: managers chain, target user, and reports tree

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#managersObject

Returns the value of attribute managers

Returns:

  • (Object)

    the current value of managers



78
79
80
# File 'lib/teems/commands/org.rb', line 78

def managers
  @managers
end

#reportsObject

Returns the value of attribute reports

Returns:

  • (Object)

    the current value of reports



78
79
80
# File 'lib/teems/commands/org.rb', line 78

def reports
  @reports
end

#targetObject

Returns the value of attribute target

Returns:

  • (Object)

    the current value of target



78
79
80
# File 'lib/teems/commands/org.rb', line 78

def target
  @target
end

Class Method Details

.json_report(user, sub_reports) ⇒ Object



88
89
90
# File 'lib/teems/commands/org.rb', line 88

def self.json_report(user, sub_reports)
  user.to_h.merge(direct_reports: json_reports(sub_reports))
end

.json_reports(reports) ⇒ Object



84
85
86
# File 'lib/teems/commands/org.rb', line 84

def self.json_reports(reports)
  reports.map { |report| json_report(*report.values_at(:user, :reports)) }
end

Instance Method Details

#to_json_hashObject



79
80
81
82
# File 'lib/teems/commands/org.rb', line 79

def to_json_hash
  { managers: managers.map(&:to_h), target: target.to_h,
    direct_reports: self.class.json_reports(reports[:reports]) }
end