Class: MOCO::Holiday

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

Overview

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

Instance Attribute Summary

Attributes inherited from BaseEntity

#attributes, #client

Class Method Summary collapse

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

Class Method Details

.entity_pathObject

Override entity_path to match API path



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

def self.entity_path
  "users/holidays"
end

Instance Method Details

#creatorObject



17
18
19
# File 'lib/moco/entities/holiday.rb', line 17

def creator
  @creator ||= client.users.find(creator_id) if creator_id
end

#to_sObject



21
22
23
# File 'lib/moco/entities/holiday.rb', line 21

def to_s
  "#{year} - #{title} - #{days} days (#{hours} hours) - #{user&.full_name}"
end

#userObject

Associations



13
14
15
# File 'lib/moco/entities/holiday.rb', line 13

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