Class: SegmentField

Inherits:
ApplicationRecord show all
Defined in:
app/models/segment_field.rb

Class Method Summary collapse

Methods inherited from ApplicationRecord

define_decrypted_attribute, define_decrypted_attributes, #errors_in_bullet_points, primary_connection, special_connection

Class Method Details

.instance_method_already_implemented?(method_name) ⇒ Boolean

Hack to get around ActiveRecord::DangerousAttributeError because of the field named “type”

Returns:

  • (Boolean)


8
9
10
# File 'app/models/segment_field.rb', line 8

def self.instance_method_already_implemented?(method_name)
  return true
end

.update_procedure(edi_field_id:, edi_segment_id:, edi_field_code:, description:, type:, sequence_no:, field_attribute:, min_length:, max_length:, length_or_mask:, value:, qualifier_code:, active:, system_record:, mandatory:, xml_reference:, xml_path:, occurence_no:, edi_field_template_id:) ⇒ Object



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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/models/segment_field.rb', line 32

def update_procedure(
  edi_field_id:,
  edi_segment_id:,
  edi_field_code:,
  description:,
  type:,
  sequence_no:,
  field_attribute:,
  min_length:,
  max_length:,
  length_or_mask:,
  value:,
  qualifier_code:,
  active:,
  system_record:,
  mandatory:,
  xml_reference:,
  xml_path:,
  occurence_no:,
  edi_field_template_id:
)
  ActiveRecord::Base.execute_procedure(
    "pr_insert_update_edi_field",
    edi_field_id,
    edi_segment_id,
    edi_field_code,
    description,
    type,
    sequence_no,
    field_attribute,
    min_length,
    max_length,
    length_or_mask,
    value,
    qualifier_code,
    active,
    system_record,
    mandatory,
    xml_reference,
    xml_path,
    occurence_no,
    edi_field_template_id
  )
end

.where_procedure(transaction_id:, segment_id:, limit: 10, offset: 0) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/models/segment_field.rb', line 13

def where_procedure(
  transaction_id:,
  segment_id:,
  limit: 10,
  offset: 0
)
  raw_data = ActiveRecord::Base.execute_procedure(
    "pr_get_edi_fields",
    transaction_id.to_i,
    segment_id.to_i
  )

  total = raw_data.length

  data = raw_data.slice(offset, limit)

  { data:, total: }
end