class ActiveFacts::Metamodel::ValueType

The ValueType class is defined in the metamodel; full documentation is not generated. This section shows the features relevant to relational mapping.

Public Instance Methods

identifier_columns() click to toggle source

The identifier_columns for a ValueType can only ever be the self-value role that was injected

# File lib/activefacts/rmap/columns.rb, line 273
def identifier_columns
  trace :columns, "Identifier Columns for #{name}" do
    raise "Illegal call to identifier_columns for absorbed ValueType #{name}" unless is_table
    if isr = injected_surrogate_role
      columns.select{|column| column.references[0].from_role == isr }
    else
      columns.select{|column| column.references[0] == self_value_reference}
    end
  end
end
is_table() click to toggle source

Returns true if this ValueType is a table

# File lib/activefacts/rmap/tables.rb, line 27
def is_table
  return @is_table if @is_table != nil

  # Always a table if marked so:
  if is_separate
    trace :absorption, "ValueType #{name} is declared independent or separate"
    @tentative = false
    return @is_table = true
  end

  # Only a table if it has references (to another ValueType)
  if !references_from.empty? && !is_auto_assigned
    trace :absorption, "#{name} is a table because it has #{references_from.size} references to it"
    @is_table = true
  else
    @is_table = false
  end
  @tentative = false

  @is_table
end
self_index() click to toggle source
# File lib/activefacts/rmap/index.rb, line 93
def self_index
  ActiveFacts::RMap::Index.new(
    nil,    # The implied uniqueness constraint is not created
    self,   # ValueType being indexed
    self,   # Absorbed object being indexed
    columns.select{|c| c.references[0].is_self_value},
    injected_surrogate_role ? false : true
  )
end