Class: ClientSideValidations::Middleware::Validators

Inherits:
Object
  • Object
show all
Defined in:
lib/client_side_validations/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Validators

Returns a new instance of Validators.



9
10
11
# File 'lib/client_side_validations/middleware.rb', line 9

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/client_side_validations/middleware.rb', line 13

def call(env)
  matches = /^\/validators\/(\w+)$/.match(env['PATH_INFO'])
  if !matches || (matches[1] == 'uniqueness' && Config.uniqueness_validator_disabled)
    @app.call(env)
  else
    "::ClientSideValidations::Middleware::#{matches[1].camelize}".constantize.new(env).response
  end
end