Exception: Seatbelt::Errors::TypeMissmatchError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/seatbelt/errors/errors.rb

Overview

Public: Will be raised if a model is assigned to a ‘has_many’ association and the models class isn’t of required type.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(awaited, got) ⇒ TypeMissmatchError

Public: Initialize a TypeMissmatchError.

awaited - The awaited objects class name got - The actual assigned objects class name.



74
75
76
77
# File 'lib/seatbelt/errors/errors.rb', line 74

def initialize(awaited, got)
  @awaited = awaited
  @got = got
end

Instance Attribute Details

#awaitedObject

Returns the value of attribute awaited.



68
69
70
# File 'lib/seatbelt/errors/errors.rb', line 68

def awaited
  @awaited
end

#gotObject

Returns the value of attribute got.



68
69
70
# File 'lib/seatbelt/errors/errors.rb', line 68

def got
  @got
end

Instance Method Details

#to_sObject

The exception message in an understandable form.

Returns the error message.



82
83
84
85
86
# File 'lib/seatbelt/errors/errors.rb', line 82

def to_s
  msg = "An instance of #{awaited} awaited but "
  msg += "get an instance of #{got}."
  return msg
end