Class: ActiveFacts::CQL::Compiler::ValueConstraint

Inherits:
Constraint show all
Defined in:
lib/activefacts/cql/compiler/constraint.rb

Instance Attribute Summary

Attributes inherited from Definition

#constellation, #source, #vocabulary

Instance Method Summary collapse

Methods inherited from Constraint

#all_bindings_in_readings, #bind_readings, #common_bindings, #loose_bind_roles, #loose_bind_wherever_possible, #loose_binding, #warn_ignored_joins

Constructor Details

#initialize(value_ranges, enforcement) ⇒ ValueConstraint

Returns a new instance of ValueConstraint.



612
613
614
615
# File 'lib/activefacts/cql/compiler/constraint.rb', line 612

def initialize value_ranges, enforcement
  super nil, enforcement
  @value_ranges = value_ranges
end

Instance Method Details

#compileObject



617
618
619
620
621
622
623
624
625
626
627
628
629
# File 'lib/activefacts/cql/compiler/constraint.rb', line 617

def compile
  @constraint = @constellation.ValueConstraint(:new)
  @value_ranges.each do |range|
    min, max = Array === range ? range : [range, range]
    v_range = @constellation.ValueRange(
      min ? [[String === min ? eval(min) : min.to_s, String === min, nil], true] : nil,
      max ? [[String === max ? eval(max) : max.to_s, String === max, nil], true] : nil
    )
    ar = @constellation.AllowedRange(@constraint, v_range)
  end
  @enforcement.compile(@constellation, @constraint) if @enforcement
  super
end