Class: Doodle::Protocol

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
AASM
Defined in:
app/models/doodle/protocol.rb

Defined Under Namespace

Classes: CreatorService, FinalizerService, FinderService

Constant Summary collapse

STATUSES =
{
  waiting:     'waiting',
  in_progress: 'in_progress',
  finalized:   'finalized'
}

Instance Method Summary collapse

Instance Method Details

#add_analyst_into(user) ⇒ Object



55
56
57
58
# File 'app/models/doodle/protocol.rb', line 55

def add_analyst_into(user)
  self.user = user
  self.save
end

#add_participant_into_conversation(login) ⇒ Object



60
61
62
63
64
# File 'app/models/doodle/protocol.rb', line 60

def add_participant_into_conversation()
  conversation = Layer::Conversation.find(self.conversation_id)
  conversation.participants << 
  conversation.save
end

#conversationObject



72
73
74
# File 'app/models/doodle/protocol.rb', line 72

def conversation
  self.conversation_id.split('/').last
end

#duration_minObject



46
47
48
49
# File 'app/models/doodle/protocol.rb', line 46

def duration_min
  return nil if self.finalized_at.blank?
  "#{(self.finalized_at - self.created_at).round / 60} min"
end

#log_status_changeObject



51
52
53
# File 'app/models/doodle/protocol.rb', line 51

def log_status_change
  Rails.logger.info "[DOODLE] [PROTOCOL] - Protocol #{self.id} of customer #{self.customer_login} changed from #{aasm.from_state} to #{aasm.to_state}"
end

#remove_participant_from_conversation(login) ⇒ Object



66
67
68
69
70
# File 'app/models/doodle/protocol.rb', line 66

def remove_participant_from_conversation()
  conversation = Layer::Conversation.find(self.conversation_id)
  conversation.participants = conversation.participants - []
  conversation.save
end