Class: DataDictionarySet

Inherits:
ApplicationRecord show all
Includes:
Models::Auditable
Defined in:
app/models/data_dictionary_set.rb

Overview

== Schema Information

Table name: data_dictionary_sets
Database name: primary

id :integer not null, primary key
default_set :boolean
destination :string(255)
set_name :string(255)

Constant Summary

Constants included from Models::Auditable

Models::Auditable::ALWAYS_IGNORED

Constants included from Models::Schedulable

Models::Schedulable::SIMPLE_FORM_OPTIONS

Instance Attribute Summary collapse

Has many collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Models::Auditable

#all_skipped_columns, #audit_reference_data, #creator, #should_not_save_version, #stamp_record, #updater

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#destinationString

Returns:

  • (String)
  • (String)


24
# File 'app/models/data_dictionary_set.rb', line 24

validates :set_name, :destination, presence: true

#set_nameString

Returns:

  • (String)
  • (String)

Validations:



24
# File 'app/models/data_dictionary_set.rb', line 24

validates :set_name, :destination, presence: true

Class Method Details

.destination_options_for_selectArray<String>

Returns:

  • (Array<String>)


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
57
# File 'app/models/data_dictionary_set.rb', line 30

def self.destination_options_for_select
  [
    "customer.company_name",
    "customer.first_name",
    "customer.middle_name",
    "customer.last_name",
    "customer.profile_id",
    "customer.primary_sales_rep_id",
    "customer.buying_group_id",
    "customer.affiliations",
    "billing_address.street1",
    "billing_address.street2",
    "billing_address.city",
    "billing_address.state_code",
    "billing_address.zip",
    "billing_address.country_iso3",
    "customer.phone",
    "customer.fax",
    "customer.email",
    "customer.website",
    "contact.title",
    "contact.first_name",
    "contact.middle_name",
    "contact.last_name",
    "contact.full_name",
    "notes"
  ]
end

.options_for_selectArray<Array(String, Integer)>

Returns:

  • (Array<Array(String, Integer)>)


60
61
62
# File 'app/models/data_dictionary_set.rb', line 60

def self.options_for_select
  order(:set_name, :destination).map { |o| [o.set_name, o.id] }
end

Instance Method Details

#data_dictionariesActiveRecord::Relation<DataDictionary>

Returns:



18
# File 'app/models/data_dictionary_set.rb', line 18

has_many :data_dictionaries

#data_import_columnActiveRecord::Relation<DataImportColumn>

Returns:



16
# File 'app/models/data_dictionary_set.rb', line 16

has_many :data_import_column

#options_for_destinationArray<Array>?

Returns:

  • (Array<Array>, nil)


65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'app/models/data_dictionary_set.rb', line 65

def options_for_destination
  case destination
  when 'billing_address.country_iso3'
    Country.countries_for_select
  when 'customer.profile_id'
    Profile.options_for_select
  when 'customer.primary_sales_rep_id'
    Employee.sales_rep_options_for_select
  when 'customer.buying_group_id'
    BuyingGroup.options_for_select
  when 'customer.tier2_program_pricing_id'
    Coupon.tier2_select_options
  end
end