Class: ActiveFacts::Metamodel::SurrogateKey
- Inherits:
-
Injection
show all
- Defined in:
- lib/activefacts/metamodel/metamodel.rb,
lib/activefacts/metamodel/extensions.rb
Constant Summary
Constants inherited
from Component
Component::RANK_DISCRIMINATOR, Component::RANK_FOREIGN, Component::RANK_IDENT, Component::RANK_INDICATOR, Component::RANK_INJECTION, Component::RANK_MANDATORY, Component::RANK_MULTIPLE, Component::RANK_NON_MANDATORY, Component::RANK_SCOPING, Component::RANK_SUBTYPE, Component::RANK_SUPER, Component::RANK_SURROGATE, Component::RANK_VALUE
Instance Method Summary
collapse
Methods inherited from Component
#all_role, #data_type, #depth, #fork_to_new_parent, #in_foreign_key, #in_natural_index, #in_primary_index, #is_in_primary, #is_mandatory, #leaves, #narrow_value_constraint, #parent_entity_type, #path, #path_mandatory, #primary_index_components, #rank_key, #rank_kind, #rank_path, #root, #uncache_rank_key
Instance Method Details
2291
2292
2293
2294
2295
2296
2297
2298
2299
|
# File 'lib/activefacts/metamodel/extensions.rb', line 2291
def
if parent && (c = parent.) != ''
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 ⇒ Object
2301
2302
2303
|
# 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 ⇒ Object
2284
2285
2286
2287
2288
2289
|
# File 'lib/activefacts/metamodel/extensions.rb', line 2284
def is_auto_assigned
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 ⇒ Object
2277
2278
2279
2280
2281
2282
|
# 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 ⇒ Object
2305
2306
2307
|
# File 'lib/activefacts/metamodel/extensions.rb', line 2305
def show_trace
trace :composition, "#{ordinal ? "#{ordinal}: " : ''}#{inspect}"
end
|