lib/schematic/generator/column.rb in schematic-0.2.1 vs lib/schematic/generator/column.rb in schematic-0.2.3
- old
+ new
@@ -1,8 +1,14 @@
module Schematic
module Generator
class Column
+ attr_accessor :restriction_classes
+ class << self
+ def restriction_classes
+ @restriction_classes ||= [Restrictions::Length, Restrictions::Enumeration, Restrictions::Numericality, Restrictions::Pattern, Restrictions::Custom]
+ end
+ end
def initialize(klass, column, additional_methods = {}, ignored_methods = {})
@klass = klass
@column = column
@additional_methods = additional_methods
@@ -14,14 +20,12 @@
builder.xs :element, "name" => @column.name.dasherize, "minOccurs" => minimum_occurrences_for_column, "maxOccurs" => "1" do |field|
field.xs :complexType do |complex_type|
complex_type.xs :simpleContent do |simple_content|
simple_content.xs :restriction, "base" => map_type(@column) do |restriction|
- Restrictions::Length.new(@klass, @column).generate(restriction)
- Restrictions::Enumeration.new(@klass, @column).generate(restriction)
- Restrictions::Pattern.new(@klass, @column).generate(restriction)
- Restrictions::Numericality.new(@klass, @column).generate(restriction)
- Restrictions::Custom.new(@klass, @column).generate(restriction)
+ self.class.restriction_classes.each do |restriction_class|
+ restriction_class.new(@klass, @column).generate(restriction)
+ end
end
end
end
end
end