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.



520
521
522
523
524
# File 'lib/graphiti/errors.rb', line 520

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

Instance Method Details

#messageObject



526
527
528
# File 'lib/graphiti/errors.rb', line 526

def message
  @model ? model_message : type_message
end

#model_messageObject



530
531
532
533
534
535
536
537
538
539
# File 'lib/graphiti/errors.rb', line 530

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



541
542
543
544
545
546
547
548
549
550
# File 'lib/graphiti/errors.rb', line 541

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