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.



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

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.



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

def body
  @body
end

#requestObject

Returns the value of attribute request.



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

def request
  @request
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#content_typeObject



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

def content_type
  'application/json'
end

#responseObject



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

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