Class: NucleusCore::ErrorView

Inherits:
View show all
Defined in:
lib/nucleus_core/views/error_view.rb

Instance Attribute Summary

Attributes inherited from SimpleObject

#__attributes__

Instance Method Summary collapse

Methods inherited from SimpleObject

#to_h

Constructor Details

#initialize(attrs = {}) ⇒ ErrorView

Returns a new instance of ErrorView.



5
6
7
8
9
10
11
12
13
# File 'lib/nucleus_core/views/error_view.rb', line 5

def initialize(attrs={})
  super(
    {}.tap do |a|
      a[:status] = attrs.fetch(:status, :unprocessable_entity)
      a[:message] = attrs.fetch(:message, nil)
      a[:errors] = attrs.fetch(:errors, [])
    end
  )
end

Instance Method Details

#json_responseObject



15
16
17
# File 'lib/nucleus_core/views/error_view.rb', line 15

def json_response
  NucleusCore::JsonResponse.new(content: to_h, status: status)
end