-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime.rb
More file actions
40 lines (27 loc) · 1.21 KB
/
runtime.rb
File metadata and controls
40 lines (27 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# frozen_string_literal: true
class Runtime < ApplicationRecord
include TokenAttr
belongs_to :namespace, optional: true
token_attr :token, prefix: 's_rt_', length: 48
has_many :runtime_statuses, inverse_of: :runtime
has_many :project_assignments, class_name: 'NamespaceProjectRuntimeAssignment', inverse_of: :runtime
has_many :projects, class_name: 'NamespaceProject', through: :project_assignments, source: :namespace_project,
inverse_of: :runtimes
has_many :data_types, inverse_of: :runtime
has_many :data_type_identifiers, inverse_of: :runtime
has_many :generic_mappers, inverse_of: :runtime
has_many :runtime_function_definitions, inverse_of: :runtime
has_many :function_definitions, through: :runtime_function_definitions
has_many :flow_types, inverse_of: :runtime
validates :name, presence: true,
length: { minimum: 3, maximum: 50 },
allow_blank: false,
uniqueness: { case_sensitive: false, scope: :namespace_id }
validates :description, length: { maximum: 500 }, exclusion: { in: [nil] }
before_validation :strip_whitespace
private
def strip_whitespace
name&.strip!
description&.strip!
end
end