Class: Castkit::ActiveRecord::InvalidModel

Inherits:
Error
  • Object
show all
Defined in:
lib/castkit/active_record/error.rb

Overview

Raised when the object passed to ‘update_model!` is not of the expected model type.

This ensures that the DataObject only attempts to update the specific model it was designed to work with.

Examples:

class UserDto < Castkit::DataObject
  include Castkit::ActiveRecord
  model User
end

UserDto.new.from_model(comment_record)
# => raises Castkit::ActiveRecord::InvalidModel

Instance Method Summary collapse

Constructor Details

#initialize(model, obj) ⇒ InvalidModel

Returns a new instance of InvalidModel.

Parameters:

  • model (Class)

    the expected model class

  • obj (Object)

    the object that was passed in



44
45
46
# File 'lib/castkit/active_record/error.rb', line 44

def initialize(model, obj)
  super("Expected instance of #{model.class}, got #{obj.class}")
end