Class: NcsNavigator::Mdes::Variable

Inherits:
Object
  • Object
show all
Defined in:
lib/ncs_navigator/warehouse/table_modeler/mdes_ext.rb

Instance Method Summary collapse

Instance Method Details

#wh_manual_validationsObject



72
73
74
75
76
77
78
79
80
# File 'lib/ncs_navigator/warehouse/table_modeler/mdes_ext.rb', line 72

def wh_manual_validations
  [
    # Other combinations of length restrictions are handled with
    # autovalidations
    if type.min_length && !type.max_length
      "validates_length_of :#{name}, :minimum => #{type.min_length}"
    end
  ].compact
end

#wh_property_options(in_table) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/ncs_navigator/warehouse/table_modeler/mdes_ext.rb', line 58

def wh_property_options(in_table)
  @wh_property_options ||=
    begin
      options = OrderedHash.new
      if in_table.wh_keys.include?(self)
        options[:key] = true
      end
      options[:required] = true if required
      options[:omittable] = true if omittable
      options[:pii] = pii unless pii.blank?
      options.merge(type.wh_type_options)
    end
end

#wh_reference_name(in_table) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/ncs_navigator/warehouse/table_modeler/mdes_ext.rb', line 82

def wh_reference_name(in_table)
  fail 'Does not apply' unless self.table_reference
  if self.name =~ /_id$/
    possible = self.name.sub(/_id$/, '')
    if in_table.variables.detect { |other_v| other_v.name == possible }
      "#{possible}_record"
    else
      possible
    end
  else
    self.name + '_record'
  end
end