Sha256: 187998d0e581f08dd6c28fc6fa42e7b079e2aaef153b7d793c30bca959ce6311

Contents?: true

Size: 589 Bytes

Versions: 26

Compression:

Stored size: 589 Bytes

Contents

module Schematic
  module Generator
    module Restrictions
      class Pattern < Base
        def generate(builder)
          for_validator ActiveModel::Validations::FormatValidator do |validator|
            if pattern = validator.options[:with]
              value = pattern.source
              value.gsub!(/^(?:\^|\\A|\\a)?/, '')
              value.gsub!(/(?:\$|\\Z|\\z)?$/, '')
              value.gsub!(/\\\$/, '$')
              value.gsub!(/\(\?:/, '(')
              builder.xs(:pattern, "value" => value)
            end
          end
        end
      end
    end
  end
end


Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
schematic-0.6.2 lib/schematic/generator/restrictions/pattern.rb
schematic-0.6.1 lib/schematic/generator/restrictions/pattern.rb
schematic-0.6.0 lib/schematic/generator/restrictions/pattern.rb
schematic-0.5.9 lib/schematic/generator/restrictions/pattern.rb
schematic-0.5.8 lib/schematic/generator/restrictions/pattern.rb
schematic-0.5.7 lib/schematic/generator/restrictions/pattern.rb
schematic-0.5.6 lib/schematic/generator/restrictions/pattern.rb
schematic-0.5.5 lib/schematic/generator/restrictions/pattern.rb
schematic-0.5.4 lib/schematic/generator/restrictions/pattern.rb
schematic-0.5.3 lib/schematic/generator/restrictions/pattern.rb
schematic-0.5.2 lib/schematic/generator/restrictions/pattern.rb
schematic-0.5.1 lib/schematic/generator/restrictions/pattern.rb
schematic-0.5.0 lib/schematic/generator/restrictions/pattern.rb
schematic-0.4.4 lib/schematic/generator/restrictions/pattern.rb
schematic-0.4.3 lib/schematic/generator/restrictions/pattern.rb
schematic-0.4.2 lib/schematic/generator/restrictions/pattern.rb
schematic-0.4.1 lib/schematic/generator/restrictions/pattern.rb
schematic-0.4.0 lib/schematic/generator/restrictions/pattern.rb
schematic-0.3.8 lib/schematic/generator/restrictions/pattern.rb
schematic-0.3.7 lib/schematic/generator/restrictions/pattern.rb