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.



481
482
483
484
485
# File 'lib/graphiti/errors.rb', line 481

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

Instance Method Details

#messageObject



487
488
489
# File 'lib/graphiti/errors.rb', line 487

def message
  @model ? model_message : type_message
end

#model_messageObject



491
492
493
494
495
496
497
498
499
500
# File 'lib/graphiti/errors.rb', line 491

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



502
503
504
505
506
507
508
509
510
511
# File 'lib/graphiti/errors.rb', line 502

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