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.



455
456
457
458
459
# File 'lib/graphiti/errors.rb', line 455

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

Instance Method Details

#messageObject



461
462
463
# File 'lib/graphiti/errors.rb', line 461

def message
  @model ? model_message : type_message
end

#model_messageObject



465
466
467
468
469
470
471
472
473
474
# File 'lib/graphiti/errors.rb', line 465

def model_message
  "    \#{@resource_class}: Tried to find Resource subclass with model \#{@model.class}, but nothing found!\n\n    Make sure all your child classes are assigned and associated to the right models:\n\n    # One of these should be assocated to model \#{@model.class}:\n    self.polymorphic = ['Subclass1Resource', 'Subclass2Resource']\n  MSG\nend\n"

#type_messageObject



476
477
478
479
480
481
482
483
484
485
# File 'lib/graphiti/errors.rb', line 476

def type_message
  "    \#{@resource_class}: Tried to find Resource subclass with model \#{@model.class}, but nothing found!\n\n    Make sure all your child classes are assigned and associated to the right models:\n\n    # One of these should be assocated to model \#{@model.class}:\n    self.polymorphic = ['Subclass1Resource', 'Subclass2Resource']\n  MSG\nend\n"