Class: MOCO::Holiday
- Inherits:
-
BaseEntity
- Object
- BaseEntity
- MOCO::Holiday
- Defined in:
- lib/moco/entities/holiday.rb
Overview
Represents a MOCO user holiday/vacation entitlement record German: “Urlaubsanspruch”
Required attributes for create:
user_id - Integer, the user this holiday entitlement belongs to
year - Integer, the year (e.g., 2024)
title - String, description (e.g., "Urlaubsanspruch 80%")
days - Integer/Float, number of vacation days entitled
Optional attributes:
creator_id - Integer, user who created this record
Read-only attributes:
id, hours (auto-calculated from days), user (Hash), creator (Hash),
created_at, updated_at
Example:
# Create holiday entitlement for a user
moco.holidays.create(
user_id: 123,
year: 2024,
title: "Annual vacation entitlement",
days: 25
)
Filtering:
moco.holidays.where(year: 2024)
moco.holidays.where(user_id: 123)
Note:
Holiday days are converted to hours using the user's daily hours setting.
10 days at 8h/day = 80 hours, 10 days at 5h/day = 50 hours.
Instance Attribute Summary
Attributes inherited from BaseEntity
Class Method Summary collapse
-
.entity_path ⇒ Object
Override entity_path to match API path.
Instance Method Summary collapse
- #creator ⇒ Object
- #to_s ⇒ Object
-
#user ⇒ Object
Associations.
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_path ⇒ Object
Override entity_path to match API path
39 40 41 |
# File 'lib/moco/entities/holiday.rb', line 39 def self.entity_path "users/holidays" end |
Instance Method Details
#creator ⇒ Object
48 49 50 |
# File 'lib/moco/entities/holiday.rb', line 48 def creator @creator ||= client.users.find(creator_id) if creator_id end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/moco/entities/holiday.rb', line 52 def to_s "#{year} - #{title} - #{days} days (#{hours} hours) - #{user&.full_name}" end |
#user ⇒ Object
Associations
44 45 46 |
# File 'lib/moco/entities/holiday.rb', line 44 def user @user ||= client.users.find(user_id) if user_id end |