Exception: Negroni::Models::MissingAttribute

Inherits:
StandardError
  • Object
show all
Defined in:
lib/negroni/models.rb

Overview

Raised if a required attribute is missing.

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ MissingAttribute

Create a MissingAttribute error with a list of attributes



11
12
13
14
# File 'lib/negroni/models.rb', line 11

def initialize(attributes)
  @attributes = attributes
  super(message)
end

Instance Method Details

#messageObject

The error message



17
18
19
20
21
22
# File 'lib/negroni/models.rb', line 17

def message
  verb, s = @attributes.count > 1 ? %w(are s) : ['is']
  list = @attributes.join(', ')

  "The following attribute#{s} #{verb} missing on your model: #{list}"
end