Module: ActiveFacts::CQL::FactTypes::FactType2

Defined in:
lib/activefacts/cql/parser/FactTypes.rb

Instance Method Summary collapse

Instance Method Details

#astObject



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/activefacts/cql/parser/FactTypes.rb', line 128

def ast
  ft = anonymous_fact_type.ast
      if !name.empty?
        # "each" is often used, and doesn't imply uniqueness
        ft.name = name.term_definition_name.value
        pragmas = name.mapping_pragmas.value
        pragmas << 'independent' if name.is_where.independent
        ft.pragmas = pragmas
      elsif !each.empty?
        # Handle the implied mandatory constraint on the appropriate role
        first_reading = ft.clauses[0]
        refs = first_reading.refs
        raise "Ambiguous 'each' implies mandatory on fact type of arity #{refs.size}" unless refs.size == 2
        q = refs[-1].quantifier
        if q
    q.min = 1  # Make the existing quantifier mandatory
        else
    refs[-1].quantifier = q = Compiler::Quantifier.new(1, nil)
        end
      end
  ft
end