Class: MOCO::Task

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

Overview

Represents a MOCO task (project service/activity type) Tasks are nested under projects: project.tasks.create(…)

Required attributes for create:

name - String, task name (e.g., "Development", "Design / UX")

Optional attributes:

billable    - Boolean, whether time on this task is billable
active      - Boolean, whether task is active
budget      - Float/Integer, budget in hours or currency
hourly_rate - Float/Integer, rate for this task (used if project billing_variant is "task")
description - String, task description

Read-only attributes (returned by API):

id, created_at, updated_at

Example:

project = moco.projects.find(123)
project.tasks.create(
  name: "Development",
  billable: true,
  hourly_rate: 150,
  budget: 100
)

Instance Attribute Summary collapse

Attributes inherited from BaseEntity

#attributes, #client

Instance Method Summary collapse

Methods inherited from BaseEntity

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

Constructor Details

This class inherits a constructor from MOCO::BaseEntity

Instance Attribute Details

#activeObject

Returns the value of attribute active.



60
61
62
# File 'lib/moco/entities.rb', line 60

def active
  @active
end

#billableObject

Returns the value of attribute billable.



60
61
62
# File 'lib/moco/entities.rb', line 60

def billable
  @billable
end

#idObject

Returns the value of attribute id.



60
61
62
# File 'lib/moco/entities.rb', line 60

def id
  @id
end

#nameObject

Returns the value of attribute name.



60
61
62
# File 'lib/moco/entities.rb', line 60

def name
  @name
end

#project_idObject

Returns the value of attribute project_id.



60
61
62
# File 'lib/moco/entities.rb', line 60

def project_id
  @project_id
end

Instance Method Details

#activitiesObject



35
36
37
# File 'lib/moco/entities/task.rb', line 35

def activities
  client.activities.where(task_id: id)
end

#projectObject

Associations



31
32
33
# File 'lib/moco/entities/task.rb', line 31

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

#to_sObject



62
63
64
# File 'lib/moco/entities.rb', line 62

def to_s
  name
end