Class: BootstrapValidatorRails::Validators::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/bootstrap_validator_rails/validators/generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(record, validator, method) ⇒ Generator

Returns a new instance of Generator.



4
5
6
7
# File 'lib/bootstrap_validator_rails/validators/generator.rb', line 4

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

Instance Method Details

#generate_html_attributesObject



9
10
11
12
13
14
# File 'lib/bootstrap_validator_rails/validators/generator.rb', line 9

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

#generate_js_optionsObject



16
17
18
19
20
21
# File 'lib/bootstrap_validator_rails/validators/generator.rb', line 16

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