Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
def complect_task
{
id: task.gid,
title: task.title,
ts: task.ts,
author: task.author_id,
holder: complect_holder
}
end
module CommonOp
def common(item)
{
id: item.gid,
title: item.title,
ts: item.ts,
author: item.author_id
}
end
end
class Event < Operation
include CommonOp
def complect_goal
common(goal).merge holder: complect_goal_content_header
end
end
class Task < Operation
include CommonOp
def complect_task
common(task).merge holder: complect_holder
end
end
ProtocolElementTypeName = [:task, :note, :event].freeze
ProtocolElementTypeName.include?(type) or fail
def self.Complect type
const_get("Complect::#{type.capitalize}").new
rescue NameError
fail "Неизвестный тип"
end
module Complect
class Event; end
class QC; end
class Tast; end
end
complect = Complect :event
Паттерны проектирования на Ruby