Class: ActiveFacts::Metamodel::ValueType

Inherits:
DomainObjectType show all
Defined in:
lib/activefacts/metamodel/metamodel.rb,
lib/activefacts/metamodel/extensions.rb

Instance Attribute Summary

Attributes inherited from ObjectType

#injected_surrogate_role

Instance Method Summary collapse

Methods inherited from ObjectType

#all_role_transitive, #is_partitioned, #is_separate, #is_static

Instance Method Details

#all_subtypeObject Also known as: subtypes



512
513
514
# File 'lib/activefacts/metamodel/extensions.rb', line 512

def all_subtype
  all_value_type_as_supertype
end

#all_supertypeObject



504
505
506
# File 'lib/activefacts/metamodel/extensions.rb', line 504

def all_supertype
  Array(supertype)
end

#common_supertype(other) ⇒ Object



521
522
523
524
525
526
# File 'lib/activefacts/metamodel/extensions.rb', line 521

def common_supertype(other)
  return nil unless other.is_a?(ActiveFacts::Metamodel::ValueType)
  return self if other.supertypes_transitive.include?(self)
  return other if supertypes_transitive.include(other)
  nil
end

#is_auto_assignedObject

Is this ValueType auto-assigned? Returns either ‘assert’, ‘commit’, otherwise nil.



529
530
531
532
533
534
535
536
# File 'lib/activefacts/metamodel/extensions.rb', line 529

def is_auto_assigned
  type = self
  while type
    return type.transaction_phase || 'commit' if type.name =~ /^Auto/ || type.transaction_phase
    type = type.supertype
  end
  nil
end

#subtypes_transitiveObject



517
518
519
# File 'lib/activefacts/metamodel/extensions.rb', line 517

def subtypes_transitive
  [self] + subtypes.map{|st| st.subtypes_transitive}.flatten
end

#supertypes_transitiveObject



508
509
510
# File 'lib/activefacts/metamodel/extensions.rb', line 508

def supertypes_transitive
  [self] + (supertype ? supertype.supertypes_transitive : [])
end