Class: Pakyow::Data::UnknownAssociation

Inherits:
Error
  • Object
show all
Defined in:
lib/pakyow/data/errors.rb

Instance Method Summary collapse

Instance Method Details

#contextual_messageObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/pakyow/data/errors.rb', line 72

def contextual_message
  if associations.any?
    String.new(
      <<~MESSAGE
        The following associations exist for #{@context.__object_name.name}:
      MESSAGE
    ).tap do |message|
      associations.each do |association|
        message << "  * #{association.name}"
      end
    end
  else
    String.new(
      <<~MESSAGE
        No associations exist for #{@context.__object_name.name}.
      MESSAGE
    )
  end
end