Sha256: fb1b1bb75647a6f847cd511dc1ac9d4585437c0fd00c7bdf506467d9773240bf

Contents?: true

Size: 859 Bytes

Versions: 2

Compression:

Stored size: 859 Bytes

Contents

module BootstrapValidatorRails
  module Validators
    class Generator
      def initialize(record, validator, method)
        @record, @validator, @method = record, validator, method
        @kind = validator.kind
      end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bootstrap_validator_rails-1.1.0 lib/bootstrap_validator_rails/validators/generator.rb
bootstrap_validator_rails-1.0.0 lib/bootstrap_validator_rails/validators/generator.rb