Class: MOCO::PlanningEntry

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

Overview

Represents a MOCO planning entry Provides methods for planning entry-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

#dealObject



16
17
18
# File 'lib/moco/entities/planning_entry.rb', line 16

def deal
  @deal ||= client.deals.find(deal_id) if deal_id
end

#projectObject



12
13
14
# File 'lib/moco/entities/planning_entry.rb', line 12

def project
  @project ||= client.projects.find(project_id) if project_id
end

#to_sObject



20
21
22
23
24
# File 'lib/moco/entities/planning_entry.rb', line 20

def to_s
  period = starts_on == ends_on ? starts_on : "#{starts_on} to #{ends_on}"
  resource = project || deal
  "#{period} - #{hours_per_day}h/day - #{user&.full_name} - #{resource&.name}"
end

#userObject

Associations



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

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