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_subtype ⇒ Object
Also known as:
subtypes
511
512
513
|
# File 'lib/activefacts/metamodel/extensions.rb', line 511
def all_subtype
all_value_type_as_supertype
end
|
#all_supertype ⇒ Object
503
504
505
|
# File 'lib/activefacts/metamodel/extensions.rb', line 503
def all_supertype
Array(supertype)
end
|
#all_value_type_parameter_transitive ⇒ Object
537
538
539
|
# File 'lib/activefacts/metamodel/extensions.rb', line 537
def all_value_type_parameter_transitive
supertypes_transitive.flat_map{|st| st.all_value_type_parameter.to_a}
end
|
#applicable_parameter_restrictions(parameter_name, include_base_type = false) ⇒ Object
541
542
543
544
545
546
547
548
549
550
|
# File 'lib/activefacts/metamodel/extensions.rb', line 541
def applicable_parameter_restrictions parameter_name, include_base_type = false
vtp = all_value_type_parameter_transitive.detect{|vtp| vtp.name == parameter_name }
return [] if !vtp || vtp.value_type == self
vtpr = all_value_type_parameter_restriction.select{|vtpr| vtpr.value_type_parameter == vtp }
if vtpr.empty?
supertype.applicable_parameter_restrictions parameter_name
else
vtpr
end
end
|
#common_supertype(other) ⇒ Object
520
521
522
523
524
525
|
# File 'lib/activefacts/metamodel/extensions.rb', line 520
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_assigned ⇒ Object
Is this ValueType auto-assigned? Returns either 'assert', 'commit', otherwise nil.
528
529
530
531
532
533
534
535
|
# File 'lib/activefacts/metamodel/extensions.rb', line 528
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_transitive ⇒ Object
516
517
518
|
# File 'lib/activefacts/metamodel/extensions.rb', line 516
def subtypes_transitive
[self] + subtypes.map{|st| st.subtypes_transitive}.flatten
end
|
#supertypes_transitive ⇒ Object
507
508
509
|
# File 'lib/activefacts/metamodel/extensions.rb', line 507
def supertypes_transitive
[self] + (supertype ? supertype.supertypes_transitive : [])
end
|