Class: Mongoid::Includes::Errors::InvalidIncludes

Inherits:
Errors::MongoidError
  • Object
show all
Defined in:
lib/mongoid/includes/errors/invalid_includes.rb

Overview

Public: This error is raised when an invalid include is performed.

Direct Known Subclasses

InvalidPolymorphicIncludes

Instance Method Summary collapse

Constructor Details

#initialize(klass, args, options) ⇒ InvalidIncludes

Public: Composes a message from the class the includes would be performed on, the relations to be included, and the options.



10
11
12
13
14
# File 'lib/mongoid/includes/errors/invalid_includes.rb', line 10

def initialize(klass, args, options)
  super compose_message(type, options.merge(
    klass: klass, relations: klass.relations.keys, args: Array.wrap(args)
  ))
end

Instance Method Details

#compose_message(type, options) ⇒ Object

Overrides: Helps to keep the templates simple by using inspect on the options.



22
23
24
25
26
# File 'lib/mongoid/includes/errors/invalid_includes.rb', line 22

def compose_message(type, options)
  super type, options.transform_values { |value|
    value.is_a?(Array) ? value.map(&:inspect).join(', ') : value.inspect
  }
end

#typeObject

Internal: Key of the translation message



17
18
19
# File 'lib/mongoid/includes/errors/invalid_includes.rb', line 17

def type
  :invalid_includes
end