Exception: Graphiti::Errors::PolymorphicResourceChildNotFound

Inherits:
Base
  • Object
show all
Defined in:
lib/graphiti/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(resource_class, type: nil, model: nil) ⇒ PolymorphicResourceChildNotFound

Returns a new instance of PolymorphicResourceChildNotFound.



436
437
438
439
440
# File 'lib/graphiti/errors.rb', line 436

def initialize(resource_class, type: nil, model: nil)
  @resource_class = resource_class
  @model = model
  @type = type
end

Instance Method Details

#messageObject



442
443
444
# File 'lib/graphiti/errors.rb', line 442

def message
  @model ? model_message : type_message
end

#model_messageObject



446
447
448
449
450
451
452
453
454
455
# File 'lib/graphiti/errors.rb', line 446

def model_message
  <<~MSG
    #{@resource_class}: Tried to find Resource subclass with model #{@model.class}, but nothing found!

    Make sure all your child classes are assigned and associated to the right models:

    # One of these should be assocated to model #{@model.class}:
    self.polymorphic = ['Subclass1Resource', 'Subclass2Resource']
  MSG
end

#type_messageObject



457
458
459
460
461
462
463
464
465
466
# File 'lib/graphiti/errors.rb', line 457

def type_message
  <<~MSG
    #{@resource_class}: Tried to find Resource subclass with model #{@model.class}, but nothing found!

    Make sure all your child classes are assigned and associated to the right models:

    # One of these should be assocated to model #{@model.class}:
    self.polymorphic = ['Subclass1Resource', 'Subclass2Resource']
  MSG
end