Class: Inferno::Repositories::Messages::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/inferno/repositories/messages.rb

Instance Method Summary collapse

Instance Method Details

#before_createObject



17
18
19
20
# File 'lib/inferno/repositories/messages.rb', line 17

def before_create
  self.id = SecureRandom.uuid
  super
end

#validateObject



22
23
24
25
26
27
28
# File 'lib/inferno/repositories/messages.rb', line 22

def validate
  super
  types = Entities::Message::TYPES
  errors.add(:message, 'must be present') if message.blank?
  errors.add(:type, 'must be present') if type.blank?
  errors.add(:type, "'#{type}' is invalid. Must be one of: #{types.join(', ')}") unless types.include?(type)
end