Class: Schematic::Generator::Restrictions::Custom

Inherits:
Base show all
Defined in:
lib/schematic/generator/restrictions/custom.rb

Instance Attribute Summary

Attributes inherited from ColumnValidator

#column, #klass

Instance Method Summary collapse

Methods inherited from ColumnValidator

#for_validator, #initialize, #validators_for_column

Constructor Details

This class inherits a constructor from Schematic::Generator::ColumnValidator

Instance Method Details

#generate(builder) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/schematic/generator/restrictions/custom.rb', line 7

def generate(builder)
  validators_for_column.each do |validator|
    if validator.respond_to?(:xsd_pattern_restrictions)
      validator.xsd_pattern_restrictions.each do |restriction|
        builder.xs(:pattern, 'value' => restriction.is_a?(Regexp) ? restriction.source : restriction)
      end
      return
    end
  end
end