Exception: Caprese::RecordInvalidError

Inherits:
Error
  • Object
show all
Defined in:
lib/caprese/errors.rb

Overview

Thrown when a record was attempted to be persisted and was invalidated

Instance Attribute Summary collapse

Attributes inherited from Error

#code, #field, #header, #t

Instance Method Summary collapse

Methods inherited from Error

#full_message, #i18n_scope, #with_header

Constructor Details

#initialize(record, engaged_field_aliases = {}) ⇒ RecordInvalidError

Returns a new instance of RecordInvalidError.



25
26
27
28
29
30
# File 'lib/caprese/errors.rb', line 25

def initialize(record, engaged_field_aliases = {})
  super()
  @record = record
  @aliases = engaged_field_aliases
  @header = { status: :unprocessable_entity }
end

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



23
24
25
# File 'lib/caprese/errors.rb', line 23

def aliases
  @aliases
end

#recordObject (readonly)

Returns the value of attribute record.



23
24
25
# File 'lib/caprese/errors.rb', line 23

def record
  @record
end

Instance Method Details

#as_jsonObject



32
33
34
# File 'lib/caprese/errors.rb', line 32

def as_json
  record.errors.as_json
end