Class: ClientSideValidations::Middleware::Uniqueness

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

Constant Summary collapse

IGNORE_PARAMS =
%w{case_sensitive id scope}
REGISTERED_ORMS =
[]

Instance Attribute Summary

Attributes inherited from Base

#body, #request, #status

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#content_type, #initialize

Constructor Details

This class inherits a constructor from ClientSideValidations::Middleware::Base

Class Method Details

.register_orm(orm) ⇒ Object



56
57
58
# File 'lib/client_side_validations/middleware.rb', line 56

def self.register_orm(orm)
  registered_orms << orm
end

.registered_ormsObject



60
61
62
# File 'lib/client_side_validations/middleware.rb', line 60

def self.registered_orms
  REGISTERED_ORMS
end

Instance Method Details

#registered_ormsObject



64
65
66
# File 'lib/client_side_validations/middleware.rb', line 64

def registered_orms
  self.class.registered_orms
end

#responseObject



45
46
47
48
49
50
51
52
53
54
# File 'lib/client_side_validations/middleware.rb', line 45

def response
  if is_unique?
    self.status = 404
    self.body   = 'true'
  else
    self.status = 200
    self.body   = 'false'
  end
  super
end