-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction_definition.rb
More file actions
56 lines (47 loc) · 2.14 KB
/
Copy pathfunction_definition.rb
File metadata and controls
56 lines (47 loc) · 2.14 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true
class FunctionDefinition < ApplicationRecord
include HasTranslation
belongs_to :runtime, inverse_of: :function_definitions
belongs_to :runtime_module, inverse_of: :function_definitions
belongs_to :runtime_function_definition
has_many :node_functions, inverse_of: :function_definition
has_many :parameter_definitions, inverse_of: :function_definition
has_translation :names, purpose: :name
has_translation :descriptions, purpose: :description
has_translation :documentations, purpose: :documentation
has_translation :deprecation_messages, purpose: :deprecation_message
has_translation :display_messages, purpose: :display_message
has_translation :aliases, purpose: :alias
scope :by_node_function, ->(node_functions) { where(node_functions: node_functions) }
validates :identifier, presence: true, uniqueness: { case_sensitive: false, scope: :runtime_id }
validates :design, length: { maximum: 200 }
delegate :parsed_version, to: :runtime_function_definition
def to_grpc
Tucana::Shared::FunctionDefinition.new(
runtime_name: identifier,
parameter_definitions: ordered_parameter_definitions.map(&:to_grpc),
signature: runtime_function_definition.signature,
throws_error: runtime_function_definition.throws_error,
name: names.map(&:to_grpc),
description: descriptions.map(&:to_grpc),
documentation: documentations.map(&:to_grpc),
deprecation_message: deprecation_messages.map(&:to_grpc),
display_message: display_messages.map(&:to_grpc),
alias: aliases.map(&:to_grpc),
linked_data_type_identifiers: runtime_function_definition.referenced_data_types.map(&:identifier),
version: runtime_function_definition.version,
display_icon: runtime_function_definition.display_icon,
definition_source: runtime_function_definition.definition_source,
runtime_definition_name: runtime_function_definition.runtime_name,
design: design
)
end
def ordered_parameter_definitions
parameter_definitions.sort_by do |definition|
[
definition.runtime_parameter_definition.id,
definition.id
]
end
end
end