Exception: DuckRecord::RecordInvalid

Inherits:
DuckRecordError show all
Defined in:
lib/duck_record/validations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record = nil) ⇒ RecordInvalid

Returns a new instance of RecordInvalid.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/duck_record/validations.rb', line 8

def initialize(record = nil)
  if record
    @record = record
    errors = @record.errors.full_messages.join(", ")
    message = I18n.t(:"#{@record.class.i18n_scope}.errors.messages.record_invalid", errors: errors, default: :"errors.messages.record_invalid")
  else
    message = "Record invalid"
  end

  super(message)
end

Instance Attribute Details

#recordObject (readonly)

Returns the value of attribute record.



6
7
8
# File 'lib/duck_record/validations.rb', line 6

def record
  @record
end