Class: Unidom::Party::Collaborating
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Unidom::Party::Collaborating
- Includes:
- Common::Concerns::ModelExtension
- Defined in:
- app/models/unidom/party/collaborating.rb
Overview
Collaborating 是参与者以特定的角色进行协作。
Class Method Summary collapse
Class Method Details
.collaborate!(collaboration: nil, collaborator: nil, name: collaborator.try(:name), role_code: nil, priority: 1, grade: 1, description: nil, instruction: nil, opened_at: Time.now) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/unidom/party/collaborating.rb', line 17 def self.collaborate!(collaboration: nil, collaborator: nil, name: collaborator.try(:name), role_code: nil, priority: 1, grade: 1, description: nil, instruction: nil, opened_at: Time.now) query = collaboration_is(collaboration).collaborated_by(collaborator).role_coded_as(role_code).valid_at(now: opened_at).alive attributes = { name: name, priority: priority, grade: grade, description: description, instruction: instruction } = query.first_or_initialize attributes if .new_record? .opened_at = opened_at else .attributes = attributes end .save! end |