class ActiveFacts::Metamodel::SurrogateKey

Public Instance Methods

comment() click to toggle source
# File lib/activefacts/metamodel/extensions.rb, line 2291
def comment
  if parent && (c = parent.comment) != ''
    return c
  end
  if fkf = all_foreign_key_field.single
    return fkf.foreign_key.composite.mapping.name + ' surrogate key'
  end
  (parent ? parent.name + ' ' : '') + 'surrogate key'
end
inspect() click to toggle source
# File lib/activefacts/metamodel/extensions.rb, line 2301
def inspect
  "#{self.class.basename} (#{rank_kind})#{parent ? " in #{parent.name}" :''} of #{name && name != '' ? name : '<anonymous>'}"
end
is_auto_assigned() click to toggle source
# File lib/activefacts/metamodel/extensions.rb, line 2284
def is_auto_assigned
  # It's auto-assigned if it's in its root's primary_index and is not a foreign key field
  root and
    (root.primary_index.all_index_field.detect{|ixf| ixf.component == self}) and
    (!all_foreign_key_field.detect{|fkf| fkf.foreign_key.source_composite == self.root})
end
is_identifying() click to toggle source
# File lib/activefacts/metamodel/extensions.rb, line 2277
def is_identifying
  if pk = root.primary_index
    return pk.all_index_field.detect{|ixf| ixf.component == self}
  end
  !parent.parent
end
show_trace() click to toggle source
# File lib/activefacts/metamodel/extensions.rb, line 2305
def show_trace
  trace :composition, "#{ordinal ? "#{ordinal}: " : ''}#{inspect}"
end