Class: MOCO::Schedule

Inherits:
BaseEntity show all
Defined in:
lib/moco/entities/schedule.rb

Overview

Represents a MOCO schedule entry Provides methods for schedule-specific associations

Instance Attribute Summary

Attributes inherited from BaseEntity

#attributes, #client

Instance Method Summary collapse

Methods inherited from BaseEntity

#==, #association, #destroy, #eql?, #has_many, #hash, #id, #initialize, #inspect, #reload, #save, #to_h, #to_json, #update

Constructor Details

This class inherits a constructor from MOCO::BaseEntity

Instance Method Details

#assignmentObject



12
13
14
15
16
17
18
19
20
# File 'lib/moco/entities/schedule.rb', line 12

def assignment
  return nil unless assignment_id

  @assignment ||= if assignment_type == "Absence"
                    client.absences.find(assignment_id)
                  else
                    client.projects.find(assignment_id)
                  end
end

#to_sObject



22
23
24
# File 'lib/moco/entities/schedule.rb', line 22

def to_s
  "#{date} - #{user&.full_name} - #{assignment&.name}"
end

#userObject

Associations



8
9
10
# File 'lib/moco/entities/schedule.rb', line 8

def user
  @user ||= client.users.find(user_id) if user_id
end