Class: ClientSideValidations::Middleware::Base

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

Direct Known Subclasses

Uniqueness

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Base

Returns a new instance of Base.



26
27
28
29
30
# File 'lib/client_side_validations/middleware.rb', line 26

def initialize(env)
  self.body    = ''
  self.status  = 200
  self.request = ActionDispatch::Request.new(env)
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



24
25
26
# File 'lib/client_side_validations/middleware.rb', line 24

def body
  @body
end

#requestObject

Returns the value of attribute request.



24
25
26
# File 'lib/client_side_validations/middleware.rb', line 24

def request
  @request
end

#statusObject

Returns the value of attribute status.



24
25
26
# File 'lib/client_side_validations/middleware.rb', line 24

def status
  @status
end

Instance Method Details

#content_typeObject



36
37
38
# File 'lib/client_side_validations/middleware.rb', line 36

def content_type
  'application/json'
end

#responseObject



32
33
34
# File 'lib/client_side_validations/middleware.rb', line 32

def response
  [status, {'Content-Type' => content_type, 'Content-Length' => body.length.to_s}, [body]]
end