Sha256: b108da6bbb56680113f4fe0f1e7b168fdc000cbd61ffec7d947e89037560d277

Contents?: true

Size: 613 Bytes

Versions: 3

Compression:

Stored size: 613 Bytes

Contents

module BootstrapValidatorRails
  module Validators
    class Generator
      VALIDATOR_SUPPORTED = [:presence, :numericality]

      def initialize(record, validator, method)
        @record, @validator, @method = record, validator, method
        @kind = validator.kind
      end

      def generate_data(options = {})
        return {} unless VALIDATOR_SUPPORTED.include?(@kind)
        klass = "BootstrapValidatorRails::Validators::#{@kind.to_s.capitalize}".constantize
        bootstrap_validator = klass.new(@record, @method, @validator)
        bootstrap_validator.generate_data
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bootstrap_validator_rails-0.1.2 lib/bootstrap_validator_rails/validators/generator.rb
bootstrap_validator_rails-0.1.1 lib/bootstrap_validator_rails/validators/generator.rb
bootstrap_validator_rails-0.1.0 lib/bootstrap_validator_rails/validators/generator.rb